SELECT
EXTRACT(YEAR FROM payment_ts) AS year,
EXTRACT(MONTH FROM payment_ts) AS mon,
SUM(amount) as rev
FROM payment
GROUP BY year, mon
ORDER BY year, mon;
Explanation
This query is selecting data from a table called "payment" and is asking Postgres to extract the year and month from a column called "payment_ts" (which likely stands for payment timestamp). It is also asking Postgres to sum the values in a column called "amount" and to alias that sum as "rev".
The query is then grouping the data by year and month, and ordering the results by year and month.
Essentially, this query is asking Postgres to provide a breakdown of payments by year and month, with the total revenue for each month. This could be useful for identifying trends in revenue over time.
Copied
Last Submission
postgres
No submission yet for this engine. Run and submit your query to save it here.
Copied
Expected results
Submit a query to compare against expected output.