Multiple counts in one query
835670Sep 18 2012 — edited Oct 18 2012Hello,
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!