I have a query like:
SELECT
id
FROM
table1
INNER JOIN
...
WHERE
...
AND eventtype IN (2000120, 2000121, 2000122, 2000123, 2000130)
EXCEPT
SELECT
id
FROM
table1
INNER JOIN
...
WHERE
...
AND eventtype IN (2000123,2000130,2000134,2000135)
Note that the queries are both identical except the last where-clause.
I would now like to count the number of records returned by this above query.
How to?
Many thanks
use COUNT and wrap it inside a SUBQUERY
SELECT COUNT(ID)
FROM (
SELECT id
FROM table1
INNER JOIN...
WHERE...
AND eventtype IN ( 2000120, 2000121, 2000122, 2000123, 2000130 )
EXCEPT
SELECT id
FROM table1
INNER JOIN...
WHERE...
AND eventtype IN ( 2000123, 2000130, 2000134, 2000135 )
) s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With