Materialized view style (concept)
SQL
Medium
0 views
Problem Description
Assume your database supports materialized views. Create one materialized view that stores monthly revenue from Orders.
Output Format
View created
Sample Test Case
Output:
Materialized view created
Constraints
Assume PostgreSQL-style DATE_TRUNC
Official Solution
CREATE MATERIALIZED VIEW mv_monthly_revenue AS SELECT DATE_TRUNC('month', order_date) AS month, SUM(total_amount) AS revenue FROM Orders GROUP BY DATE_TRUNC('month', order_date);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!