Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL help!
Hi fumi,
Okay, where did I go wrong? I just looked at the SQL and I don't see the problem. I thought that since I am comparing on both week_nbr and store_nbr (which appear to be the only identifying columns in the query) that the desired result should be obtained.
regards
Jerry Gitomer
fumi wrote in message <7n3irj$4g4$9_at_news.seed.net.tw>...
>
>Jerry Gitomer <jgitomer_at_hbsrx.com> wrote in message
>news:7mvjbh$54d$1_at_autumn.news.rcn.net...
>> If I understand your problem correctly the following
should
>> do the trick.
>> SELECT ty.week_nbr,
>> ty.week_dsc,
>> ty.store_nbr,
>> ty.store_name,
>> ly.sum(nvl(regsales,0)) as ly_reg_sales,
>> ty.sum(nvl(regsales,0)) as ty_reg_sales,
>> ly.sum(nvl(regunits,0)) as ly_reg_units,
>> ty.sum(nvl(regunits,0)) as ty_reg_units,
>> ly.sum(nvl(promosales,0)) as ly_promosales,
>> ty.sum(nvl(promosales,0)) as ty_promosales,
>> ly.sum(nvl(promounits,0)) as ly_promounits,
>> ty.sum(nvl(promounits,0)) as ty_promounits
>> FROM RSNET.JC_STORE_BY_WEEK ty,
>> RSNET.JC_STORE_BY_WEEK ly
>> WHERE ty.week_nbr >= 199828
>> AND ty.week_nbr <=199927
>> AND ly.week_nbr = ty.week_nbr + 100
>> AND ty.store_nbr = ly.store_nbr
>> GROUP BY ty.week_nbr, ty.week_dsc, ty.store_nbr, ty.store_name
>> ORDER BY ty.week_nbr, ty.store_nbr
>
>
>If you do so, the Cartesian's Product will take effect.
>The sum would be multiple of the real values.
>
>
>
Received on Wed Jul 21 1999 - 08:55:47 CDT
![]() |
![]() |