Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Help: Converting Teradata Case to Oracle Decode

Re: Help: Converting Teradata Case to Oracle Decode

From: Uday <un2000_at_hotmail.com>
Date: 21 Nov 2001 12:32:26 -0800
Message-ID: <fcf0102e.0111211232.77348cf8@posting.google.com>


You need an aggregate function for the group by. Your SQL statement does not have a sum() function with the decodes. might wanna try something like
select u.price_plan_code, sum( decode....)), sum( decode(....)) ......
group by u.price_plan_code;
Also, GROUP BY does a sort so in this case, you need not use the ORDER BY clause.

jpquinn_at_home.com (Jay Quinn) wrote in message news:<3bf566d6.16858576_at_news>...
> Hi, here is my Teradata SQL that uses a CASE statement which runs
> fine.
>
> select price_plan_code,
> SUM(CASE WHEN CYCLE_RUN_MONTH = '08' AND CYCLE_RUN_YEAR = '2001' THEN
> REPORTED_TIME_DUR ELSE 0 END) AUG_USAGE,
> SUM(CASE WHEN CYCLE_RUN_MONTH = '09' AND CYCLE_RUN_YEAR = '2001' THEN
> REPORTED_TIME_DUR ELSE 0 END) SEP_USAGE
> FROM LD_ACCESS_VIEWS.VSLU001_USAGE_DETAIL
> GROUP BY 1
> ORDER BY 1
>
> Here is my Oracle SQL with a Decode statement thus far. It gives me
> the error, line 2: not a GROUP BY expression., I know it is though.
>
> select u.price_plan_code,
> decode (u.cycle_run_month, '08', u.reported_time_dur),
> decode (u.cycle_run_year, '2001', u.reported_time_dur) Aug_Usage,
> decode (u.cycle_run_month, '09', u.reported_time_dur),
> decode (u.cycle_run_year, '2001, u.reported_time_dur) Sep_Usage
> FROM US0108 u
> where u.cycle_code = '1'
> and u.cycle_run_month = '08'
> and u.cycle_run_year = '2001'
> GROUP BY u.price_plan_code
> ORDER BY u.price_plan_code
> /
>
> I need the Oracle Decode Syntax, if anyone could please share it with
> me and take a look at this code and recommend some changes.
>
> Thanks, Jay
Received on Wed Nov 21 2001 - 14:32:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US