From 1f1fbbb3bb6c30889d716ad8dcacd3e3a8c10a55 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Mon, 21 Feb 2022 15:52:55 -0600 Subject: [PATCH 1/3] saving changes .gitignore --- .gitignore | 2 +- project_notes.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c76d08a..4e5b8f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -projectnotes.md* +projectnotes.md diff --git a/project_notes.md b/project_notes.md index b22b748..df61d6b 100644 --- a/project_notes.md +++ b/project_notes.md @@ -29,3 +29,7 @@ are valid ways of forming the query. ## Resources [How to concatenate columns in SQL - CONCAT_WS()](https://www.w3schools.com/sql/func_mysql_concat_ws.asp) +## New Concepts/Syntax + +SQLite
+`strftime('%Y', InvoiceDate` \ No newline at end of file From 53f11e1a7bc7929d94eca992faac251b8251fa36 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Mon, 21 Feb 2022 15:53:22 -0600 Subject: [PATCH 2/3] Saving end of day changes --- invoice_totals.sql | 10 ++++++++++ total_invoices_{year}.sql | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 invoice_totals.sql create mode 100644 total_invoices_{year}.sql diff --git a/invoice_totals.sql b/invoice_totals.sql new file mode 100644 index 0000000..ed0a5bd --- /dev/null +++ b/invoice_totals.sql @@ -0,0 +1,10 @@ +SELECT + INVOICE.Total, CUSTOMER.FirstName, CUSTOMER.LastName, EMPLOYEE.FirstName, Employee.LastName, Invoice.BillingCountry +FROM + ((Customer +INNER JOIN + Employee ON Employee.EmployeeId = Customer.SupportRepId) +INNER JOIN + INVOICE ON INVOICE.CustomerId = Customer.CustomerId) +ORDER BY + INVOICE.Total DESC; diff --git a/total_invoices_{year}.sql b/total_invoices_{year}.sql new file mode 100644 index 0000000..b09f841 --- /dev/null +++ b/total_invoices_{year}.sql @@ -0,0 +1,6 @@ +SELECT strftime('%Y', InvoiceDate) as Year, + COUNT(*) as InvoiceCount +FROM Invoice +WHERE strftime('%Y', InvoiceDate) = '2009' + OR strftime('%Y', InvoiceDate) = '2011' +GROUP BY strftime('%Y', InvoiceDate); From 9bb77ddeeca1ef24ae9d44236e28a75d661861b6 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Mon, 21 Feb 2022 15:59:04 -0600 Subject: [PATCH 3/3] final commit for the day --- project_notes.md | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 project_notes.md diff --git a/project_notes.md b/project_notes.md deleted file mode 100644 index df61d6b..0000000 --- a/project_notes.md +++ /dev/null @@ -1,35 +0,0 @@ -# Project Notes - SQL Interlude - Chinook - -## Questions -### How to use NOT in queries -Why does - -``` -SELECT * FROM CUSTOMER -WHERE COUNTRY NOT LIKE 'USA'; -``` - -work and - -``` -SELECT * FROM CUSTOMER -WHERE COUNTRY NOT 'USA'; -``` -does not work? - -### Answer -To avoid using `LIKE`
- -`WHERE NOT customer.country = "USA";`
-or
-`WHERE NOT != "USA";`
- -are valid ways of forming the query. - -## Resources -[How to concatenate columns in SQL - CONCAT_WS()](https://www.w3schools.com/sql/func_mysql_concat_ws.asp) - -## New Concepts/Syntax - -SQLite
-`strftime('%Y', InvoiceDate` \ No newline at end of file