SELECT
p.name,
SUM(o.total_price) AS total_revenue,
MONTH(o.timestamp) AS month,
YEAR(o.timestamp) AS year
FROM products p
JOIN orders o
ON p.product_id = o.product_id
WHERE o.timestamp >= DATEADD(year, -1, GETDATE())
GROUP BY p.name, month, year
ORDER BY total_revenue DESC
LIMIT 10
WITH monthly_revenue AS (
SELECT
p.product_id,
p.name,
p.category,
SUM(o.total_price) AS total_revenue,
MONTH(o.timestamp) AS month,
YEAR(o.timestamp) AS year
FROM products p
JOIN orders o
ON p.product_id = o.product_id
GROUP BY p.product_id, p.name, p.category, month, year
)
SELECT mr.name, mr.category,
(mr.total_revenue - LAG(mr.total_revenue) OVER (PARTITION BY mr.category ORDER BY mr.year, mr.month))
/ LAG(mr.total_revenue) OVER (PARTITION BY mr.category ORDER BY mr.year, mr.month) AS revenue_growth_rate
FROM monthly_revenue mr
HAVING revenue_growth_rate >= 0.5
We use a fine-tuned model to generate SQL queries from plain English. These queries are tailored to your database based on computed embeddings from user-provided descriptions of the database structure. Post-processing checks for correctness and flags possible issues.
By default, we do not store any of your data. Your database structure is fed to the model in order to generate query output.
Database information is stored in your browser and is not saved on our server, unless you explicitly save it using the Save or Share functionality. You can delete your information at any time.
The best way to find out is to try it yourself. We're constantly improving things, so results will get better over time. You'll also become more productive with this tool as you adopt the best practices and get used to its quirks.
QueryMuse is an assistant. You should always proofread and understand any a generated query before running it.
The more information you provide about your database, the better the results will be. You can fill out information about your database on the Databases page. Use the column details field to provide as much context on each column as possible.