Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiple counts in one query

835670Sep 18 2012 — edited Oct 18 2012
Hello,

I am trying to get multiple counts into one query.
Each of the count queries work perfectly fine when done seperately, but the problem comes when I try to use them all together.
The code is like this:

SELECT
(SELECT count(*) FROM randomtable WHERE variable = 'first') as good1,
(SELECT count(*) FROM randomtable WHERE variable = 'second') as good2

Should show up something similar to:
good1 good2
12 8

Basically, the goal here is to just get the count numbers to show up.
The problem I am running into is that the first SELECT statement requires me to have a FROM table, which I don't need.
If I do insert a table, then the counts will show up in the number of rows that show up in the FROM table.
It'll end up showing something like:
good1 good2
12 8
12 8
12 8
12 8
12 8
etc.


Is there something I am missing here or do I need an alternative?

Thank you!
This post has been answered by Sven W. on Sep 18 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2012
Added on Sep 18 2012
6 comments
20,979 views