Skip to content

Commit 7d03686

Browse files
authored
Update Cahllenge 1 Steve's car showroom.md
1 parent 44005d1 commit 7d03686

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

Cahllenge 1 Steve's car showroom.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,68 @@ Here are the tables you will be using:
1515

1616
## Table Creation:
1717
```sql
18-
-- SQL code to create the required tables
18+
USE steel_data;
19+
CREATE TABLE cars (
20+
car_id INT PRIMARY KEY,
21+
make VARCHAR(50),
22+
type VARCHAR(50),
23+
style VARCHAR(50),
24+
cost_$ INT
25+
);
26+
--------------------
27+
INSERT INTO cars (car_id, make, type, style, cost_$)
28+
VALUES (1, 'Honda', 'Civic', 'Sedan', 30000),
29+
(2, 'Toyota', 'Corolla', 'Hatchback', 25000),
30+
(3, 'Ford', 'Explorer', 'SUV', 40000),
31+
(4, 'Chevrolet', 'Camaro', 'Coupe', 36000),
32+
(5, 'BMW', 'X5', 'SUV', 55000),
33+
(6, 'Audi', 'A4', 'Sedan', 48000),
34+
(7, 'Mercedes', 'C-Class', 'Coupe', 60000),
35+
(8, 'Nissan', 'Altima', 'Sedan', 26000);
36+
--------------------
37+
CREATE TABLE salespersons (
38+
salesman_id INT PRIMARY KEY,
39+
name VARCHAR(50),
40+
age INT,
41+
city VARCHAR(50)
42+
);
43+
--------------------
44+
INSERT INTO salespersons (salesman_id, name, age, city)
45+
VALUES (1, 'John Smith', 28, 'New York'),
46+
(2, 'Emily Wong', 35, 'San Fran'),
47+
(3, 'Tom Lee', 42, 'Seattle'),
48+
(4, 'Lucy Chen', 31, 'LA');
49+
--------------------
50+
CREATE TABLE sales2 (
51+
sale_id INT PRIMARY KEY,
52+
car_id INT,
53+
salesman_id INT,
54+
purchase_date DATE,
55+
FOREIGN KEY (car_id) REFERENCES cars(car_id),
56+
FOREIGN KEY (salesman_id) REFERENCES salespersons(salesman_id)
57+
);
58+
--------------------
59+
INSERT INTO sales2 (sale_id, car_id, salesman_id, purchase_date)
60+
VALUES (1, 1, 1, '2021-01-01'),
61+
(2, 3, 3, '2021-02-03'),
62+
(3, 2, 2, '2021-02-10'),
63+
(4, 5, 4, '2021-03-01'),
64+
(5, 8, 1, '2021-04-02'),
65+
(6, 2, 1, '2021-05-05'),
66+
(7, 4, 2, '2021-06-07'),
67+
(8, 5, 3, '2021-07-09'),
68+
(9, 2, 4, '2022-01-01'),
69+
(10, 1, 3, '2022-02-03'),
70+
(11, 8, 2, '2022-02-10'),
71+
(12, 7, 2, '2022-03-01'),
72+
(13, 5, 3, '2022-04-02'),
73+
(14, 3, 1, '2022-05-05'),
74+
(15, 5, 4, '2022-06-07'),
75+
(16, 1, 2, '2022-07-09'),
76+
(17, 2, 3, '2023-01-01'),
77+
(18, 6, 3, '2023-02-03'),
78+
(19, 7, 1, '2023-02-10'),
79+
(20, 4, 4, '2023-03-01');
1980
```
2081
## Ad-Hoc Questions and Solutions
2182
### 1. What are the details of all cars purchased in the year 2022?

0 commit comments

Comments
 (0)