Good job! The last thing we'll show you in this part is how to do revenue reports for the current year, month, etc. They're another frequent financial report, and they show how much the company earned so far in the given current period. Commonly used report types are:
- year-to-date (YTD) – refers to the period beginning the first day of the current calendar year up to the current date.
- month-to-date (MTD) – refers to the period of time between the 1st of the current month and the current date.
- quarter-to-date (QTD) – refers to the period of time between the beginning of the current quarter and the current date.
YTD, MTD, and QTD reports are used by business owners, investors, and individuals to analyze their revenue, income, business earnings, and investment returns for the current period of time.
For example, if we want to show the month-to-date revenue:
SUM(amount) AS total_revenue
FROM orders o
JOIN customers c
ON o.customer_id = c.customer_id
WHERE order_date >= DATE_TRUNC('month', CURRENT_TIMESTAMP)
GROUP BY c.customer_id, company_name;
If you look at the
WHERE clause, you can see we used the technique we learned in the previous exercise to compute the beginning of the current month.