Skip to content

Commit b444609

Browse files
Merge pull request CharlieButterworth#2 from CharlieButterworth/cb-tests
Cb tests
2 parents c0f5197 + 33597e0 commit b444609

28 files changed

+131
-0
lines changed

Chinook.session.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT LastName,
2+
FirstName,
3+
CustomerId,
4+
Country
5+
from Customer
6+
WHERE Country NOT LIKE "USA"

brazil_customers.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT LastName,
2+
FirstName,
3+
CustomerId,
4+
Country
5+
from Customer
6+
WHERE Country LIKE "Brazil"

brazil_customers_invoices.sql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT FirstName,
2+
LastName,
3+
InvoiceId,
4+
InvoiceDate,
5+
Country
6+
FROM Invoice
7+
INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId
8+
WHERE Country LIKE "Brazil"

country_invoices.sql

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT COUNT(InvoiceId),
2+
BillingCountry
3+
FROM Invoice
4+
GROUP BY BillingCountry

invoice_37_line_item_count.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT InvoiceId,
2+
COUNT(InvoiceLineId)
3+
FROM InvoiceLine
4+
WHERE InvoiceId = 37
5+
GROUP BY InvoiceId;

invoice_totals.sql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT i.InvoiceId,
2+
c.firstName CustomerName,
3+
e.firstName SalesAgentName,
4+
c.Country,
5+
i.total
6+
FROM Employee e
7+
JOIN Customer c ON e.EmployeeId = c.SupportRepId
8+
JOIN Invoice i on i.CustomerId = c.CustomerId

invoices_line_item_count.sql

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT COUNT(InvoiceLine)
2+
FROM Invoice i
3+
JOIN Invoice ON i.id = InvoiceLine.invoice_id

line_item_track.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT InvoiceId,
2+
InvoiceLineId,
3+
t.name
4+
FROM InvoiceLine i
5+
JOIN Track t ON i.TrackId = t.TrackId;

line_item_track_artist.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT i.InvoiceLineId,
2+
t.Name,
3+
t.composer
4+
FROM InvoiceLine i
5+
JOIN Track t ON i.TrackId = t.TrackId;

line_items_per_invoice.sql

Whitespace-only changes.

non_usa_customers.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT LastName,
2+
FirstName,
3+
CustomerId,
4+
Country
5+
from Customer
6+
WHERE Country NOT LIKE "USA"

playlists_track_count.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT COUNT(playlisttrack.trackid),
2+
playlist.name
3+
FROM Playlist,
4+
playlisttrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId
5+
GROUP BY playlist.PlaylistId

sales_agent_customer_count.sql

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT MAX(NumberOfCustomers),
2+
EmployeeName
3+
FROM (
4+
SELECT e.firstName || `` || e.lastName as EmployeeName,
5+
COUNT(c.CustomerId) as NumberOfCustomers
6+
FROM Employee e
7+
JOIN Customer c ON c.SupportReppId = e.EmployeeId
8+
GROUP BY e.firstName
9+
)

sales_agent_invoices.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT DISTINCT Employee.firstName,
2+
Employee.lastName,
3+
InvoiceId
4+
From Invoice
5+
JOIN Customer ON Invoice.CustomerId = Customer.CustomerId
6+
JOIN Employee ON Employee.EmployeeId = Customer.SupportRepId

sales_agent_total_sales.sql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT SUM(i.Total) AS TotalSales,
2+
e.FirstName,
3+
e.LastName
4+
FROM Invoice i
5+
JOIN Customer c ON c.CustomerId = i.CustomerId
6+
JOIN Employee e ON e.EmployeeId = c.SupportRepId
7+
GROUP BY e.EmployeeId
8+
ORDER BY TotalSales DESC

sales_agents.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT firstName,
2+
lastName,
3+
Title
4+
FROM Employee
5+
Where Title LIKE "Sales Support Agent"

sales_per_country.sql

Whitespace-only changes.

top_2009_agent.sql

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
SELECT MAX(TotalSales),
2+
EmployeeName
3+
FROM (
4+
SELECT "$" || printf("%.2f", SUM(i.Total)) AS TotalSales,
5+
e.FirstName || '' || e.LastName AS EmployeeName,
6+
strftime ('%Y', i.InvoiceDate) AS InvoiceYear
7+
FROM Invoice i,
8+
Employee e,
9+
Customer c
10+
WHERE i.CustomerId = c.CustomerId
11+
AND c.SupportRepId = e.EmployeeId
12+
AND InvoiceYear = '2009'
13+
GROUP BY EmployeName,
14+
InvoiceYear
15+
) AS Sales;

top_2013_track.sql

Whitespace-only changes.

top_3_artists.sql

Whitespace-only changes.

top_5_tracks.sql

Whitespace-only changes.

top_agent.sql

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT SUM(i.Total) AS TotalSales,
2+
e.FirstName,
3+
e.LastName
4+
FROM Invoice i
5+
JOIN Customer c ON c.CustomerId = i.CustomerId
6+
JOIN Employee e ON e.EmployeeId = c.SupportRepId
7+
GROUP BY e.EmployeeId
8+
ORDER BY TotalSales DESC
9+
limit 1

top_country.sql

Whitespace-only changes.

top_media_type.sql

Whitespace-only changes.

total_invoices_{year}.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT COUNT(i.InvoiceId) NumberOfInvoices,
2+
STRFTIME('%Y', i.InvoiceDate) InvoiceYear
3+
FROM Invoice i
4+
WHERE InvoiceYear = '2011'
5+
OR InvoiceYear = '2009'
6+
GROUP BY InvoiceYear

total_sales-year.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SELECT printf('%.2f', SUM(i.Total)) Total,
2+
strftime('%Y', i.InvoiceDate) InvoiceYear

tracks_no_id.sql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT al.title AlbumTitle,
2+
t.name,
3+
mediatype.name Media,
4+
genre.name
5+
FROM Track t
6+
JOIN Album al ON t.AlbumId = al.AlbumId
7+
JOIN Genre ON Genre.GenreId = t.GenreId
8+
JOIN MediaType ON MediaType.MediaTypeId = t.MediaTypeId

unique_invoice_countries.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SELECT DISTINCT BillingCountry
2+
FROM Invoice

0 commit comments

Comments
 (0)