I'm having a hard time finding the words to describe my problem, so Google is not turning up any results. Sorry for what is (probably) a very simple question.
Basically I want to have two rows, both of which are created by individual between statements. I've tried using an "AS" statement like I would in a Select, but that just gives me a syntax error.
Here's my code:
Select WEEK_ID,
SUM (CUR_CHARGE_UNITS) as "Pro Units"
From DW******.SLS****
Where (WEEK_ID Between '201201' And '201252') --Use 'as' statement here?
Or (WEEK_ID Between '201101' And '201152')
Group By WEEK_ID
Basically I'm trying to figure out how to make
WEEK_ID Between '201201' And '201252'
collapse into one row titled "2012". Like I said, all I've tried is
(WEEK_ID Between '201201' And '201252) As "2012"
Any thoughts? Any tutorials anyone wants to point me at? Any insults for not knowing the answer to a presumably basic question?
group by substr(week_id, 0, 4)
, whatever your db's equivalent of the substring function is? – Marc B Jan 9 '13 at 17:00