diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c76d08a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +projectnotes.md* diff --git a/brazil_customers.sql b/brazil_customers.sql new file mode 100644 index 0000000..2c9a2a2 --- /dev/null +++ b/brazil_customers.sql @@ -0,0 +1,2 @@ +SELECT FirstName, LastName, Country FROM CUSTOMER +WHERE Country = 'Brazil'; \ No newline at end of file diff --git a/brazil_customers_invoices.sql b/brazil_customers_invoices.sql new file mode 100644 index 0000000..810a065 --- /dev/null +++ b/brazil_customers_invoices.sql @@ -0,0 +1,12 @@ +SELECT + Customer.FirstName, Customer.LastName, Invoice.InvoiceId, Invoice.InvoiceDate, Invoice.BillingCountry +FROM + Invoice +INNER JOIN + Customer +ON + Invoice.CustomerId = Customer.CustomerId +WHERE + Invoice.BillingCountry = 'Brazil' +ORDER BY + LastName ASC; \ No newline at end of file diff --git a/non_usa_customers.sql b/non_usa_customers.sql new file mode 100644 index 0000000..1aaf752 --- /dev/null +++ b/non_usa_customers.sql @@ -0,0 +1,2 @@ +SELECT CustomerId, FirstName, Country FROM CUSTOMER +WHERE COUNTRY != 'USA'; \ No newline at end of file diff --git a/project_notes.md b/project_notes.md new file mode 100644 index 0000000..b22b748 --- /dev/null +++ b/project_notes.md @@ -0,0 +1,31 @@ +# 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/sales_agent_invoices.sql b/sales_agent_invoices.sql new file mode 100644 index 0000000..7741fff --- /dev/null +++ b/sales_agent_invoices.sql @@ -0,0 +1,14 @@ +SELECT + EMPLOYEE.FirstName, EMPLOYEE.LastName, InvoiceId +FROM + Employee +INNER JOIN + INVOICE +ON + CUSTOMER.CustomerId = INVOICE.CustomerId +INNER JOIN + Customer +ON + Customer.SupportRepId = Employee.EmployeeId +ORDER BY + InvoiceId ASC; \ No newline at end of file diff --git a/sales_agents.sql b/sales_agents.sql new file mode 100644 index 0000000..b6512c4 --- /dev/null +++ b/sales_agents.sql @@ -0,0 +1,8 @@ +SELECT DISTINCT + EMPLOYEE.FirstName, EMPLOYEE.LastName +FROM + EMPLOYEE +INNER JOIN + Customer +ON + EMPLOYEE.EmployeeId = Customer.SupportRepId; \ No newline at end of file diff --git a/unique_invoice_countries.sql b/unique_invoice_countries.sql new file mode 100644 index 0000000..d74a2b4 --- /dev/null +++ b/unique_invoice_countries.sql @@ -0,0 +1,5 @@ +SELECT DISTINCT + BillingCountry +FROM + INVOICE; +