diff --git a/.gitignore b/.gitignore index c76d08a..4e5b8f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -projectnotes.md* +projectnotes.md 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/project_notes.md b/project_notes.md deleted file mode 100644 index b22b748..0000000 --- a/project_notes.md +++ /dev/null @@ -1,31 +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) - 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);