Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> When SUM is null or zero

When SUM is null or zero

From: Marco Shaw <marco_at_Znbnet.nb.ca>
Date: Thu, 04 Aug 2005 13:06:28 GMT
Message-ID: <opoIe.70021$Ph4.2177612@ursa-nb00s0.nbnet.nb.ca>


**Alert: Oracle & SQL newbie**

I want to write a report in SQL. Here's a sample table I want to report on:

server_name severity log_only notification_only

------------  -------- --------  ----------------
serverA        critical    0           0
serverA        critical    1           0
serverA        major     1           0
serverB        major     0           0

The last two columns can only be a zero or one.

I want a report written in SQL that produces something like:

server_name no of messages log_only notification_only

------------  ---------------  ---------  ----------------
serverA        3                       2             0
serverB        1                        0            0

I can easily produce a report with the first 2 columns. Someone indicated that completing the report with the last 2 columns could easily be done using SUM to count the total value of the applicable columns.

What I have determined after some testing is that if, for example, the SUM of the 4th column from the table adds up to 0, then the final report will completely drop the 4th column, and only give me something like

server_name no of messages log_only
------------ --------------- ---------

serverA        3                       2
serverB        1                        0

So how can I take this into account in SQL to make sure the ouput still produces a 0 in the 4th column of the report?

Thanks,
Marco Received on Thu Aug 04 2005 - 08:06:28 CDT

Original text of this message

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