Monthly Sales Trends (chinook database)
Medium
32
1
92.8% Acceptance
In this lab, you'll work with the SQLite-based Chinook database to perform various SQL operations. The objective is to test and sharpen your SQL skills.
Dataset Description
The dataset you'll be working with is the Chinook database, which contains multiple tables like Artist
, Album
, Track
, Invoice
, etc., each having specific fields. Make sure to refer to the table schema before starting the challenges.
Task
Calculate the total sales for each month. Your task is to write an SQL query that sums up the sales for each month from the Invoice
table.
- Tables Involved:
Invoice
- Output Columns:
Month
,TotalSales
Specific Instructions
- Use
strftime('%Y-%m', "InvoiceDate")
to format the date into 'YYYY-MM' format. Alias this as"Month"
. - Sum the
"Total"
column in theInvoice
table and alias it as"TotalSales"
. - Group your results by
"Month"
. - Order your results by
"Month"
.
Challenge
Objective: Calculate the total sales for each month from the Invoice
table.
- Tables Involved:
Invoice
- Columns in Output:
Month
,TotalSales
Specifics:
- Use
strftime('%Y-%m', "InvoiceDate")
to format the date into 'YYYY-MM' format and alias it asMonth
. - Sum up the
Total
column and alias it asTotalSales
. - Group the results by
Month
. - Order the results by
Month
.
Make sure to use double quotes for column and table names.