linfo2172-databases/P3/queries/query6.sql

11 lines
383 B
SQL

-- Determine the total number of purchases for each of the last ten days. List the date, as well as the total number of purchases.
-- Expected Heading: RELATION {time INTEGER, cnt INTEGER}
-- How do you treat the default case as showed in the instructions?
SELECT time, COUNT(*) AS cnt
FROM Purchases
where time > date((SELECT MAX(time) FROM Purchases),'-10 days')
GROUP BY time
;