Oracle SQL 개발자 사용하고 있습니다. I have a table 본질적으로 사진 갖고 있는 열:
[DATE_CREATED 날짜, NUM_of_PICTURES (int)]
select *, 꼭 이래야겠어요 다음과 비슷한 출력입니다 아웃하기로 나는한다 가져옵니다.
01-May-12 12
02-May-12 15
03-May-12 09
...
...
01-Jun-12 20
...
etc.
나는 이 자금을 집계) 로 하고 대신 사진 월 숫자임 매일.
select Month(DATE_CREATED), sum(Num_of_Pictures))
from pictures_table
group by Month(DATE_CREATED);
이 출력입니다 오류가 발생했습니다.
ORA-00904: "MONTH": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 5 Column: 9
월 기능을 보유하고 있는 잘못된 것일까?
내가 약간만이라도 강해 이어 포함시키십시오 출력입니다. 한 가지 방법은.
select to_char(DATE_CREATED, 'YYYY-MM'), sum(Num_of_Pictures)
from pictures_table
group by to_char(DATE_CREATED, 'YYYY-MM')
order by 1
또 다른 방법은 (계속 표준 SQL):
select extract(year from date_created) as yr, extract(month from date_created) as mon,
sum(Num_of_Pictures)
from pictures_table
group by extract(year from date_created), extract(month from date_created)
order by yr, mon;
Remember the order by 너회가 추정되는 이 순서, 이후 스맥랜드의 대한 보장은 리하여 행뿐만 한 뒤 나님이시거늘 그룹순.
For Oracle:
select EXTRACT(month from DATE_CREATED), sum(Num_of_Pictures)
from pictures_table
group by EXTRACT(month from DATE_CREATED);