Query Question
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
On Jan 22, 9:49 am, wackyph... [at] 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
I think you may be on to it. But I get NULL for 'NewSlnCount'. Why
would SUM report NULL?
Re: Query Question
Nevermind I got it working thanks to your example.
Thank you.