From c976ea2420607c8265ff46385e6a7f5f9a6b102d Mon Sep 17 00:00:00 2001 From: paulie Date: Wed, 19 Jun 2024 10:57:42 +0000 Subject: [PATCH 1/6] Main --- mysqlcodes/query1.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 mysqlcodes/query1.sql diff --git a/mysqlcodes/query1.sql b/mysqlcodes/query1.sql new file mode 100644 index 0000000..1200d34 --- /dev/null +++ b/mysqlcodes/query1.sql @@ -0,0 +1 @@ +SELECT * FROM \ No newline at end of file From 0591ee161411e825a76d4d29e16646924d9bb6a2 Mon Sep 17 00:00:00 2001 From: paulie Date: Wed, 19 Jun 2024 12:21:30 +0000 Subject: [PATCH 2/6] commit --- mysqlcodes/query1.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqlcodes/query1.sql b/mysqlcodes/query1.sql index 1200d34..9b04320 100644 --- a/mysqlcodes/query1.sql +++ b/mysqlcodes/query1.sql @@ -1 +1 @@ -SELECT * FROM \ No newline at end of file +SELECT * FROM employee \ No newline at end of file From 3c04415dc7e2da0c40cb83b8516b114a481cab9f Mon Sep 17 00:00:00 2001 From: paulie Date: Wed, 19 Jun 2024 12:22:19 +0000 Subject: [PATCH 3/6] commit --- .vscode/settings.json | 1 - mysqlcodes/query1.sql | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9bc98c8..20de972 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,7 +18,6 @@ "screencastMode.onlyKeyboardShortcuts": true, "terminal.integrated.fontSize": 18, "window.zoomLevel": 3, - "workbench.activityBar.visible": true, "workbench.colorTheme": "Default Light+", "workbench.fontAliasing": "antialiased", "workbench.statusBar.visible": true, diff --git a/mysqlcodes/query1.sql b/mysqlcodes/query1.sql index 9b04320..d861ce1 100644 --- a/mysqlcodes/query1.sql +++ b/mysqlcodes/query1.sql @@ -1 +1,2 @@ -SELECT * FROM employee \ No newline at end of file +SELECT * FROM employee + where firstName = 'Wilie' \ No newline at end of file From 62b794ed5088ed7825f0eaae60ef0297237fee92 Mon Sep 17 00:00:00 2001 From: paulie Date: Wed, 19 Jun 2024 15:58:52 +0000 Subject: [PATCH 4/6] commit --- Scripts/02-02.sql | 2 +- Scripts/query3.sql | 1 + mysqlcodes/query1.sql | 7 +++++-- mysqlcodes/query2.sql | 6 ++++++ 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 Scripts/query3.sql create mode 100644 mysqlcodes/query2.sql diff --git a/Scripts/02-02.sql b/Scripts/02-02.sql index 3bbdf2d..43bb2ff 100644 --- a/Scripts/02-02.sql +++ b/Scripts/02-02.sql @@ -8,7 +8,7 @@ SELECT emp.employeeId, FROM sales sls INNER JOIN employee emp ON sls.employeeId = emp.employeeId -WHERE sls.soldDate >= date('now','start of year') +WHERE sls.soldDate >= date(2022-01-01) GROUP BY emp.employeeId, emp.firstName, emp.lastName diff --git a/Scripts/query3.sql b/Scripts/query3.sql new file mode 100644 index 0000000..c59d9b6 --- /dev/null +++ b/Scripts/query3.sql @@ -0,0 +1 @@ +d \ No newline at end of file diff --git a/mysqlcodes/query1.sql b/mysqlcodes/query1.sql index d861ce1..48e259d 100644 --- a/mysqlcodes/query1.sql +++ b/mysqlcodes/query1.sql @@ -1,2 +1,5 @@ -SELECT * FROM employee - where firstName = 'Wilie' \ No newline at end of file +SELECT e1.firstName ,e1.lastName , e2.firstName as Manager_Name + +FROM employee e1 +LEFT JOIN employee as e2 +on e1.managerId = e2.employeeId; \ No newline at end of file diff --git a/mysqlcodes/query2.sql b/mysqlcodes/query2.sql new file mode 100644 index 0000000..ee38f5f --- /dev/null +++ b/mysqlcodes/query2.sql @@ -0,0 +1,6 @@ +SELECT e.employeeId,e.firstName,e.lastName,count(s.employeeId) as CarsSold +FROM employee e +LEFT JOIN sales s +ON e.employeeId = s.employeeId +GROUP BY e.employeeId,e.firstName,e.lastName +ORDER BY CarsSold DESC \ No newline at end of file From 5fffa11e0c2fa8333d150d5f610f7706a3cd2ced Mon Sep 17 00:00:00 2001 From: paulie Date: Wed, 19 Jun 2024 16:16:01 +0000 Subject: [PATCH 5/6] commit --- Scripts/query3.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Scripts/query3.sql b/Scripts/query3.sql index c59d9b6..3b66b76 100644 --- a/Scripts/query3.sql +++ b/Scripts/query3.sql @@ -1 +1,8 @@ -d \ No newline at end of file +SELECT e.employeeId,e.firstName,e.lastName,count(s.salesId) as car_count, +max(s.salesAmount) AS max,min(s.salesAmount) as min +FROM employee e +LEFT JOIN sales s +ON e.employeeId = s.employeeId +GROUP BY e.employeeId,e.firstName,e.lastName +HAVING count(s.salesId) > 5 +ORDER by car_count DESC From 062720a94a0282027fa1ed295a89bcd7906e5067 Mon Sep 17 00:00:00 2001 From: paulie Date: Fri, 21 Jun 2024 17:10:25 +0000 Subject: [PATCH 6/6] commit --- Scripts/03-03.sql | 2 +- {Scripts => mysqlcodes}/query3.sql | 0 mysqlcodes/query4.sql | 3 +++ mysqlcodes/query5.sql | 7 +++++++ mysqlcodes/query6.sql | 7 +++++++ 5 files changed, 18 insertions(+), 1 deletion(-) rename {Scripts => mysqlcodes}/query3.sql (100%) create mode 100644 mysqlcodes/query4.sql create mode 100644 mysqlcodes/query5.sql create mode 100644 mysqlcodes/query6.sql diff --git a/Scripts/03-03.sql b/Scripts/03-03.sql index d790317..dbad32d 100644 --- a/Scripts/03-03.sql +++ b/Scripts/03-03.sql @@ -18,7 +18,7 @@ WHERE EngineType = 'Electric'; -- Final query -SELECT sls.soldDate, sls.salesAmount, inv.colour, inv.year +SELECT sls.salesId,sls.soldDate, sls.salesAmount, inv.colour, inv.year FROM sales sls INNER JOIN inventory inv ON sls.inventoryId = inv.inventoryId diff --git a/Scripts/query3.sql b/mysqlcodes/query3.sql similarity index 100% rename from Scripts/query3.sql rename to mysqlcodes/query3.sql diff --git a/mysqlcodes/query4.sql b/mysqlcodes/query4.sql new file mode 100644 index 0000000..238bbfc --- /dev/null +++ b/mysqlcodes/query4.sql @@ -0,0 +1,3 @@ +SELECT strftime('%Y',soldDate),sum(salesAmount) +from sales +GROUP BY strftime('%Y',soldDate) \ No newline at end of file diff --git a/mysqlcodes/query5.sql b/mysqlcodes/query5.sql new file mode 100644 index 0000000..9976955 --- /dev/null +++ b/mysqlcodes/query5.sql @@ -0,0 +1,7 @@ +SELECT e.employeeId,strftime('%m',s.soldDate),sum(s.salesAmount) +from sales s +LEFT JOIN employee e ON e.employeeId = s.employeeId +WHERE s.soldDate >= '2021-01-01' +AND s.soldDate < '2022-01-01' +GROUP BY e.employeeId,strftime('%m',s.soldDate) +ORDER BY e.employeeId,strftime('%m',s.soldDate) \ No newline at end of file diff --git a/mysqlcodes/query6.sql b/mysqlcodes/query6.sql new file mode 100644 index 0000000..c21400d --- /dev/null +++ b/mysqlcodes/query6.sql @@ -0,0 +1,7 @@ +SELECT s.salesId +from sales s +LEFT JOIN inventory i +on s.inventoryId = i.inventoryId + LEFT JOIN model m + on i.modelId = m.modelId + WHERE EngineType = 'Electric'