Forum Discussion
MrSaravani
Feb 17, 2023Copper Contributor
create table with one column from two fields min and max date from another table
I want to create table with one column from two fields min and max date from another table
HarshKumar994
Feb 18, 2023Brass Contributor
Consider you have an Order table CREATE TABLE orders ( order_id int PRIMARY KEY, order_date date ); We can create a new table called "date_range" with one column "range" that contains the minimum and maximum order dates from the "orders" table using the following SQL statement: CREATE TABLE date_range ( range daterange ); INSERT INTO date_range (range) SELECT daterange(MIN(order_date), MAX(order_date)) FROM orders;