Query Question

Query Question

am 22.01.2008 15:49:55 von wackyphill

Is it possibe to combine the results of these 2 queries into a single
result set consisting of 1 row and 2 columns (for each value)?

SELECT COUNT(*) AS 'SlnCount' FROM Request WHERE RequestTypeID = 2
SELECT COUNT(*) AS 'NewSlnCount' FROM Request WHERE RequestTypeID = 2
AND StatusID = 1

Re: Query Question

am 22.01.2008 17:46:24 von zeldorblat

On Jan 22, 9:49 am, wackyph...@yahoo.com wrote:
> Is it possibe to combine the results of these 2 queries into a single
> result set consisting of 1 row and 2 columns (for each value)?
>
> SELECT COUNT(*) AS 'SlnCount' FROM Request WHERE RequestTypeID = 2
> SELECT COUNT(*) AS 'NewSlnCount' FROM Request WHERE RequestTypeID = 2
> AND StatusID = 1

SELECT COUNT(*) AS 'SlnCount',
SUM(CASE WHEN StatusID = 1 THEN 1 ELSE 0 END) AS 'NewSlnCount'
FROM Request
WHERE RequestTypeID = 2

Re: Query Question

am 22.01.2008 18:21:13 von wackyphill

I think you may be on to it. But I get NULL for 'NewSlnCount'. Why
would SUM report NULL?

Re: Query Question

am 22.01.2008 19:39:38 von wackyphill

Nevermind I got it working thanks to your example.

Thank you.