Sum column for a certain time period
SQL> CREATE TABLE sales(
2 product_id NUMBER(6),
3 cid NUMBER,
4 time_id DATE,
5 channel_id CHAR(1),
6 promo_id NUMBER(6),
7 sold NUMBER(3),
8 amount NUMBER(10,2),
9 cost NUMBER(10,2)
10 );
Table created.
SQL>
SQL> select sum(amount)
2 from sales
3 where time_id between to_date('2006-02-01', 'YYYY-MM-DD') and to_date('2006-02-28', 'YYYY-MM-DD');
SUM(AMOUNT)
-----------
1 row selected.
SQL>
SQL> drop table sales;
Table dropped.
Related examples in the same category