Insert using SELECT
SQL
Easy
3 views
Problem Description
Create a backup table OrdersBackup and copy only last month's orders into it (full rows).
Input Format
SQL DDL + DML
Output Format
Table + rows created
Sample Test Case
Input:
Orders(order_date, ...)
Constraints
Assume PostgreSQL-style DATE_TRUNC
Official Solution
CREATE TABLE OrdersBackup AS SELECT * FROM Orders WHERE order_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') AND order_date < DATE_TRUNC('month', CURRENT_DATE);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!