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 -> SQL Problem.

SQL Problem.

From: <ashesh48_at_my-dejanews.com>
Date: Wed, 12 Aug 1998 14:02:46 GMT
Message-ID: <6qs7a5$qhj$1@nnrp1.dejanews.com>


Hi All,

   I stuck in the following type of query. Lets say i have following table...

AccountNo                     Acct_code                     Units

-------------------------------------------------------------------------
123456789 000001 1000 123456789 xxxxxxx 2000 123456789 000002 3000 123456789 000003 1000 100000001 000004 2000 100000001 000005 500 100000002 000006 2000 100000003 xxxxxx 500

We need the output like if the Account No. has acct_code = xxxxxxxx then print the that as acct_code and sum all the Units. Otherwise if we dont have Acct_code = xxxxxxxx then dont print anything in Acct_code column and just print only one record...

The Output is should be as folllow...

AccountNo                     Acct_code                     Units

-------------------------------------------------------------------------
123456789 xxxxxxx 7000 100000001 2500 100000002 2000 100000003 xxxxxx 500

I am getting problem with the AccountNo 123456789. I am getting two records because of use of Union and DECODE. But i need only one record out of it. ...

Thanks for your reply in advance.
Ashesh

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Wed Aug 12 1998 - 09:02:46 CDT

Original text of this message

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