Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Group by: Not getting expected output
Please consider the query:
SELECT tcode,
COUNT(*) AS GradeEq2to3
FROM info
WHERE tavg >= 2
AND tavg < 3
GROUP BY tcode
ORDER BY tcode;
The info table contains the fields tcode and tavg. When I run the query, I got the expected output i.e. tcode and the corresponding count for tavg for the specified condition. But the query ignores the 0 count i.e. I want to display all the tcode's. If this condition is not satisfied for a particular tcode and the corresponding entry should be 0.
For example, presently I am getting the output as:
TCode GradeEq2to3
......... ....................
ABC 16 CDE 12 EFG 13 GHI 14
There are entries for which the condition (tavg >= 2 AND tavg < 3) is not satisfied. I want output in the format.
TCode GradeEq2to3
......... ....................
ABC 16 XYZ 0 CDE 12 EFG 13 GHI 14 ZAB 0
How to alter/design query for the same?
-Sameer Received on Wed May 10 2006 - 06:45:09 CDT