Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this Query Possible? 1

Status
Not open for further replies.

venur

MIS
Aug 26, 2003
418
US
Hi All,

I was wondering, do I going to the get the output with one single query .

Temp_Table has 3 col's

Temp_Table Values

PName PAmt PType
---------------------------------
Type1 100 1
Type2 100 1
Type3 100 1
Type1 50 2
Type2 50 2
Type1 25 1

PType 1 = Approved
2 = Pending


The output should be

PName Approved Pending
-------------------------------------
Type1 125 50
Type2 100 50
Type3 100 0

I can generate this report with 2 query's is that possible with one single query. Which helps me to reduce my calls to the DB.

Thank you in advance.
venu
 
select pname, sum(decode(ptype, 1, pamt, 0) approved
, sum(decode(ptype, 2, pamt, 0) pending
from temp_table
group by pname;
 
Hi,

WOW, That was quick Wonboodoo. I appreciate it.
Thank you very much.

Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top