Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: stupid SQL question
Please try:
select sum( decode ( status, 'VALID', 1, 0 )) valid, sum( decode status, 'INVALID', 1 , 0 )) invalid
from user_objects where object_type = 'VIEW'
HTH,
Michael
> I'm trying to determine object totals, along with the breakdown of
> valid/invalid. No problem so far, but I'd like to format the report
> neatly by getting all three counts on the same line. Is there any way
> to do this using straight SQL, or should I give up and use PL/SQL
> instead? I've seen similar things done by giving a table multiple
> aliases in the query, but can't seem to make it work here. Suggestions
> and/or pointers would be most appreciated.
>
> Here's an (obviously) broken example, just in case I wasn't clear
> above...
>
> select count(a.status), count(b.status), count(c.status)
> from user_objects a, user_objects b, user_objects c
> where a.object_type = 'VIEW'
> and b.object_type = 'VIEW'
> and c.object_type = 'VIEW'
> and b.status = 'VALID'
> and c.status = 'INVALID'
>
> Thanx!
>
> --
> My employers like me, but not enough to let me speak for them.
>
> Greg Norris
> Sprint LTD Database Administration
> Internet: gregory.t.norris_at_mail.sprint.com
Received on Wed Dec 13 2000 - 17:38:08 CST
![]() |
![]() |