I am using Oracle SQL Developer.
I essentially have a table of pictures that holds the columns:
[DATE_CREATED(date), NUM_of_PICTURES(int)]
and if I do a select *, I would get an output similar to:
01-May-12 12
02-May-12 15
03-May-12 09
...
...
01-Jun-12 20
...
etc.
I am trying to aggregate these sums of pictures into MONTHLY numbers instead of DAILY.
I’ve tried doing something like:
select Month(DATE_CREATED), sum(Num_of_Pictures))
from pictures_table
group by Month(DATE_CREATED);
This outputs an error:
ORA-00904: "MONTH": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 5 Column: 9
Do I have the Month function wrong?
I would be inclined to include the year in the output. One way:
Another way (more standard SQL):
Remember the order by, since you presumably want these in order, and there is no guarantee about the order that rows are returned in after a group by.