select
create_date
,resolved_date
,to_char(create_date, 'YYYY') as year_create
,to_char(create_date, 'MM') as month_create
,to_char(create_date, 'WW') as week_create
,to_char(create_date,'Q') as quarter_create
,to_char(resolved_date, 'YYYY') as year_resolved
,to_char(resolved_date, 'MM') as month_resolved
,to_char(resolved_date, 'WW') as week_resolved
,to_char(resolved_date,'Q') as quarter_resolved
,item
,site
,status
,contact_time
,impact_label
from mytable
where
create_date between to_date('2013/03/01','YYYY/MM/DD') and to_date('2015/08/06','YYYY/MM/DD')
and case item
when '1' then 'a'
when '2' then 'b'
when '3' then 'c'
else null
end
group by
create_date
,resolved_date
,to_char(create_date, 'YYYY')
,to_char(create_date, 'MM')
,to_char(create_date, 'WW')
,to_char(create_date,'Q')
,to_char(resolved_date, 'YYYY')
,to_char(resolved_date, 'MM')
,to_char(resolved_date, 'WW')
,to_char(resolved_date,'Q')
,item
,site
,status
,contact_time
,impact_label
order by item, site, create_date;
Can someone please help me spot the error of
invalid relational operator
(it says at group by line). I don't see where I possibly left out ><= ?
group byclause at all? It doesn't appear that you're doing any aggregation. Second, in yourwhereclause, you have acasestatement but you're not comparing the result of that statement to anything. I have no idea what you're trying to accomplish with thatcasestatement so it's hard to guess what you intended.group byis only used when you want to group rows together and aggregate data. It sounds like you can remove thegroup by. If you want thecasestatement to change what is presented, you'd want that to be in theselectclause as an additional column in the projection not in thewhereclause.group bywhen your query includes an aggregate function on some columns. Otherwise, there is no point to grouping the rows. You can include agroup bywithout an aggregate function. It just slows the query down for no reason and makes it more painful to support.