Oracle SQL group by week /month -


how can group reocrds weekly/monthly in oracle between date , date 1 record can returned 1 week/month.

e.g if have 5 records ist weeek , 3 records second week between date , date should return total 2 records(one ist week , 1 second week).

thanks in advance.

you can group results using group by: http://www.techonthenet.com/oracle/group_by.php

to select between date , date use where

edit

for selecting begining of week or month, can use trunc(the_date_field, ): http://www.techonthenet.com/oracle/functions/trunc_date.php

for example groups week:

select trunc(datecol_name, 'ww') table_name group trunc(datecol_name, 'ww'); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -