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
- HarshKumar994Brass ContributorConsider 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;
- olafhelperBronze ContributorSorry, it's more then unclear what you mean. How does the bases table look like (DDL), then existing data (DML) and why a new table and not simply a view?