SQL Explorer
Demo Environment
This environment resets nightly. Any data or connections you add are public.
SQL Explorer
New Query
Playground
Connections
Annotations
Logs
Favorites
Most popular products this quarter
no such table: Orders
Title
northwind.db
sqlite-sakila.db
MSSQL
trial
Connection
Description
SQL
WITH SalesData AS ( SELECT o.OrderID, strftime('%Y', o.OrderDate) AS Year, (strftime('%m', o.OrderDate) - 1) / 3 + 1 AS Quarter, od.ProductID, od.Quantity, od.UnitPrice * od.Quantity AS SalesAmount FROM Orders o JOIN "Order Details" od ON o.OrderID = od.OrderID ), RecentQuarter AS ( SELECT Year, Quarter FROM SalesData ORDER BY Year DESC, Quarter DESC LIMIT 1 ) SELECT sd.ProductID, p.ProductName, SUM(sd.Quantity) AS TotalQuantitySold, SUM(sd.SalesAmount) AS TotalSales FROM SalesData sd JOIN RecentQuarter rq ON sd.Year = rq.Year AND sd.Quarter = rq.Quarter JOIN Products p ON sd.ProductID = p.ProductID GROUP BY sd.ProductID, p.ProductName ORDER BY TotalQuantitySold DESC;
Assistant Example
Save & Run
Save Only
Download...
CSV
JSON
Show Schema
Hide Schema
SQL Assistant
Loading...
Assistant prompt
"Ask Assistant" to try and automatically fix the issue. The assistant is already aware of error messages & context.
Ask Assistant
Avg. execution: 763.005ms. Query created by admin on 2024-05-15.
History