SQLTeam.com | Weblogs | Forums

Counting daily into monthly via nested select statement


hello, i'm using SQL - via Oracle Toad 12 and i need some help with my code.
i'm relatively new to SQL - i can do the most basic things, but this one is a little bit more complicated.
hoping someone can let me know what i'm doing wrong.

the inner SELECT statement works perfectly, but when i try to sum up the initial daily select statement into a monthly one i run into trouble


trunc(Day, 'yyyy-mm') as "Month",



to_char(DATETIME, 'yyyy-mm-dd') as "Day",
count(distinct(CUSTOMER_ID)) as Frequency




DATETIME BETWEEN TO_DATE ('2017-01-01', 'yyyy-mm-dd') AND TO_DATE ('2017-07-31', 'yyyy-mm-dd')

Group by
to_char(DATETIME, 'yyyy-mm-dd'))

Group By
trunc(Day, 'yyyy-mm')


This is a SQL Server forum. Therefore, you will likely get better responses to your q from a different, more Oracle-based forum.