Home » SQL & PL/SQL » SQL & PL/SQL » SQL Output Formatting
SQL Output Formatting [message #325616] Fri, 06 June 2008 14:16 Go to next message
deay
Messages: 51
Registered: August 2005
Member
Hello

I have the below sql script:

select a.state, p.fundcode,sum(p.payamount), count(p.payamount)
from payment p, address a
where p.payamount between .01 and 4999.99
and p.paydate between to_date('01-JAN-2007','DD-MON-YYYY') and to_date('31-JAN-2007','DD-MON-YYYY')
and p.idnumber=a.idnumber
group by a.state, p.fundcode


here's a snippet of the output:

ST FUNDCODE   SUM(P.PAYAMOUNT) COUNT(P.PAYAMOUNT)
-- ---------- ---------------- ------------------
AK DH                     100                  2
AK DHH                     75                  3
AK DK                     130                  4
AK DN                      75                  1


I need formatted to look like the following:
          DH          DHH        DK         DN

AK     $100  2      $75  3    $130  4     $75  1
AL     $150  2     $175  3    $190  5     $25  1


I'd appreciate any help on how to get the output coded
to look like the format above.

thanks
Re: SQL Output Formatting [message #325617 is a reply to message #325616] Fri, 06 June 2008 14:39 Go to previous messageGo to next message
Michel Cadot
Messages: 64110
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Search for "pivot", it is a classical one answered every week.
Have also a look at TO_CHAR function.

Regards
Michel
icon14.gif  Re: SQL Output Formatting [message #325915 is a reply to message #325617] Mon, 09 June 2008 08:54 Go to previous messageGo to next message
deay
Messages: 51
Registered: August 2005
Member
thank you, I found what I needed.

Re: SQL Output Formatting [message #327009 is a reply to message #325915] Fri, 13 June 2008 06:43 Go to previous message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

deay wrote on Mon, 09 June 2008 08:54
thank you, I found what I needed.






hey deay,

can u post the desired query ??
Previous Topic: Query
Next Topic: help needed on query
Goto Forum:
  


Current Time: Mon Dec 05 10:59:48 CST 2016

Total time taken to generate the page: 0.14489 seconds