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

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL help!

Re: SQL help!

From: fumi <fumi_at_tpts5.seed.net.tw>
Date: 21 Jul 1999 04:38:17 GMT
Message-ID: <7n3irp$4g4$10@news.seed.net.tw>

KTL <webmaster_at_rs-net.com> wrote in message news:37932714.16EA1282_at_rs-net.com...
> I need to return a result set for this year/last year data.. all from
> the same table..
> I need the information in the same line..
> How do I do this in Oracle?
>
> SELECT week_nbr,
> week_dsc,
> store_nbr,
> store_name,
> sum(nvl(regsales,0)) as ty_reg_sales,
> null,
> sum(nvl(regunits,0)) as ty_reg_units,
> null,
> sum(nvl(promosales,0)) as ty_promosales,
> null,
> sum(nvl(promounits,0)) as ty_promounits,
> null
> FROM RSNET.JC_STORE_BY_WEEK
> WHERE week_nbr >= 199828 and week_nbr <=199927
>
> UNION
>
> SELECT week_nbr,
> week_dsc,
> store_nbr,
> store_name,
> null,
> sum(nvl(regsales,0)) as ly_reg_sales,
> null,
> sum(nvl(regunits,0)) as ly_reg_units,
> null,
> sum(nvl(promosales,0)) as ly_promosales,
> null,
> sum(nvl(promounits,0)) as ly_promounits
> FROM RSNET.JC_STORE_BY_WEEK
> WHERE week_nbr >= 199728 and week_nbr <=199827
> GROUP BY week_nbr,week_dsc,store_nbr,store_name
> ORDER BY week_nbr,store_nbr
>
> The nulls are there as place holders so the other query can fill the
> value...

Oracle treats NULL as a zero-length string. You should use TO_NUMBER(NULL) here, instead of sole NULL. Received on Tue Jul 20 1999 - 23:38:17 CDT

Original text of this message

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