Base Three ("2122002"...Get it? <grin>) and the rest of the responders,
Here are the issues that I see with the responses:
1) The various solutions result from
Base Three's unclear specifications of exactly how s/he wants the output to appear...Does s/he want one line of output or many?
2) "USAGE" is an Oracle reserved word with special meaning under special circumstances. That is why I changed the spelling to "USG".
3)
Turkbear's output appears this way:
[tt]
TO_C YR USG COUNT(*)
---- ---- --- ----------
2004 2004 Yes 1
2005 2005 1
2005 2005 Yes 1[/tt]
Because of the unclear output-design specifications, I cannot determine if this is how
Base Three wants it to look.
4)
Dagon's code has some syntax issues (besides "USAGE"):
a) "to_charr" should be "to_char",
b) TO_NUMBER function is missing a closing paren, in both occurrences.
Once the syntax issues are resolved (and we add some SQL*Plus "COL" definitions to aesthetically clean up the output appearance), the output is:
[tt]
Year Usage Yes Usage Null Usage
---------- ---------- ---------- ----------
2004 1 0 0
2005 1 0 1
[/tt]
...which are incorrect results...2005's Usage should be "2", not "1".
DJBjr's code has a syntax issue:
a) "null count" should read "null_count"
Once the syntax issue is resolved, here is
DJBjr's code output:
[tt]
C_YE SUM(YEAR_COUNT) SUM(YES_COUNT) SUM(NULL_COUNT)
---- --------------- -------------- ---------------
2004 1 0 0
2005 2 0 1
[/tt]
2122002 said:
SantaMusafa, djbjr and Dagon I need your modfication to your query as I am interested to know many syntax to Oracle Query.
What modification do you need to my query?
Let us know your thoughts.
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
[
Providing low-cost remote Database Admin services]
Click here to join
Utah Oracle Users Group on Tek-Tips if you use
Oracle in
Utah USA.