Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Whats wrong with this decode sql query.
TR wrote:
> Hi,
>
> I want to use a nested sql using decode.
> I have given the following command:
>
> SELECT A.TYPE,
> (SELECT SUM(DECODE(TYPE,'HOT',1,0)) HOT_CAKE,
> SUM(DECODE(TYPE,'SWEET',1,0)) SWEET_CAKE
> FROM PRODUCT_DETAIL
> WHERE PRODUCT_CODE = 1
> GROUP BY TYPE) A,
> (SELECT SUM(DECODE(TYPE,'HOT',1,0)) HOT_BURGER,
> SUM(DECODE(TYPE,'SWEET',1,0)) SWEET_BURGER
> FROM PRODUCT_DETAIL
> WHERE PRODUCT_CODE = 2
> GROUP BY TYPE) B
> WHERE A.TYPE = B.TYPE;
>
> Can any one plz tell me what's wrong in the above command and show me
> the correct one.
>
> Thank you.
>
> TR.
You really need to do your own homework. But my "helpful" hint is that you seem to be greatly over-complicating the query. Look at the demos I referred you to.
-- Daniel A. Morgan http://www.psoug.org damorgan_at_x.washington.edu (replace x with u to respond)Received on Wed Mar 08 2006 - 13:55:54 CST