Home » SQL & PL/SQL » SQL & PL/SQL » Grand Total column
Grand Total column [message #8658] Wed, 17 September 2003 13:00 Go to next message
Heidi
Messages: 37
Registered: February 2000
Member
han someone please tell me how How do I add a last column that totals the other four columns? My output looks like this....

Facility Code GATEIN ESTIMATE REPAIR GATEOUT
ATVIECTXA 0 3 0 0
AUBTBPOBA 0 5 0 0
AUFRETMPA 0 8 0 0
BEANRACEF 0 1 0 0
BRITJMSMA 0 11 0 0
etc

and here is my query...

SELECT
/* DM200-Statistical TAR Summary */
DTD.depot as "Facility Code" ,
count (decode(DTD.event_type, 'GATEIN' , 1)) GATEIN ,
count (decode(DTD.event_type, 'ESTIMATE', 1)) ESTIMATE ,
count (decode(DTD.event_type, 'REPAIR' , 1)) REPAIR ,
count (decode(DTD.event_type, 'GATEOUT' , 1)) GATEOUT
FROM
webmethods.dm_transsum_detail DTD,
( select distinct owner_code, recipient from webmethods.dm_partners ) DP
WHERE DTD.receiver = dp.owner_code
AND DTD.event_type in ('GATEIN','GATEOUT','ESTIMATE','REPAIR')
AND /* DP recipient = :partycode */
DP.recipient = 'TRI'
AND DTD.receiver = 'USSFOTRIB'
AND /* DTD.timestamp between :dateBegin and to_date(:dateEnd, 'Dd-Mon-YY')+1 */
DTD.timestamp between '10-SEP-03' and to_date('16-SEP-03', 'Dd-Mon-YY')+1
AND (DTD.rec_status_msg not in ('No Partnership Info Found','No Partnership Info found')
OR DTD.rec_status_msg IS NULL)
AND DTD.rec_status in ('FAILED', 'Failed')
AND rownum <500
GROUP BY
DTD.depot,
DTD.event_type

Many thanks in advance!!
Heidi
Re: Grand Total column [message #8662 is a reply to message #8658] Wed, 17 September 2003 15:20 Go to previous message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Heidi,

Since every row has to have one of the four values as an event_type, why not just add COUNT(*) to your SELECT clause?

A.
Previous Topic: Impact of Analyze on already running SQL?
Next Topic: Procedure Store
Goto Forum:
  


Current Time: Thu Apr 25 23:57:30 CDT 2024