Get Started Free

21. Every day of December, including the quiet ones Solved

AdvancedHarddate spinerange()LEFT JOIN

Return the number of orders placed on every day of December 2024, including days with none: day (a DATE) and orders. Sort by day.

Your answer returns 31 rows with the columns day, orders. Order matters.

The data

The store from the DuckDB playground, running in your browser with DuckDB. Prices are in EUR; the data covers 2024.

customers20 rows
idINTEGER
primary key
nameVARCHAR
countryVARCHAR
currencyVARCHAR
EUR, GBP, USD or JPY
signed_upDATE
tagsVARCHAR[]
a list: vip, newsletter, b2b, returns-often
products10 rows
idINTEGER
primary key
nameVARCHAR
categoryVARCHAR
priceDECIMAL(10,2)
EUR
specsSTRUCT
weight_g INTEGER, color VARCHAR, sizes VARCHAR[]
orders300 rows
idINTEGER
primary key
customer_idINTEGER
→ customers.id
placed_atTIMESTAMP
2024
statusENUM
placed, paid, shipped, delivered, returned
currencyVARCHAR
the customer's currency
order_items576 rows
order_idINTEGER
→ orders.id
product_idINTEGER
→ products.id
quantityINTEGER
unit_priceDECIMAL(10,2)
EUR
web_events20,000 rows
event_idBIGINT
tsTIMESTAMP
session_idVARCHAR
customer_idINTEGER
NULL for anonymous visitors
event_typeVARCHAR
page_view, search, add_to_cart, checkout
pageSTRUCT
path, referrer
deviceSTRUCT
browser, mobile BOOLEAN, screen STRUCT(w, h)
product_idsINTEGER[]
load_msINTEGER
fx_rates720 rows
currencyVARCHAR
USD, GBP, JPY
valid_fromTIMESTAMP
per_eurDOUBLE
units of currency per 1 EUR

Hints

Common traps
  • count(*) counts the empty day itself as 1: count an orders column instead.

Solution

Run in the editor with Ctrl/⌘ + Enter. Check with Shift + Ctrl/⌘ + Enter.

"Check answer" runs your SQL on a fresh copy of the data, then on 2 hidden test datasets with more customers and orders, and compares each result with the expected one. The result of your last statement is your answer.

Starting…