|
-
July 18th, 2005, 05:33 AM
#1
How Do I join all this
select count(*) as printed from quote_request_table
where convert(varchar,request_date,103) = convert(varchar,getdate(),103) and Status = 1
select count(*) as errors from quote_request_table
where convert(varchar,request_date,103) = convert(varchar,getdate(),103) and Status = 2
select count(*) as reprint from quote_request_table
where convert(varchar,request_date,103) = convert(varchar,getdate(),103) and Status = 3
select count(*) as totals from quote_request_table
where convert(varchar,request_date,103) = convert(varchar,getdate(),103)
This is SQLServer 2000
I want a result returned for each of the above statements in a single line. Union doesn't work because if say the first 2 are 0, 3rd is 3 and the 4th is 10, then I only get three results being returned 0,3,10 when I want 0,0,3,10
Thanks
If you find my answers helpful, dont forget to rate me 
-
July 18th, 2005, 05:53 AM
#2
Re: How Do I join all this
With subqueries that return 1 value you can:
Code:
select
(inner select #1),
(inner select #2),
(inner select #3)
or in your case, something like:
Code:
select
(select count(*) from quote_request_table where convert(varchar, request_date, 103) = convert(varchar, getdate(), 103) and Status = 1) as printed,
(select count(*) from quote_request_table where convert(varchar, request_date, 103) = convert(varchar, getdate(), 103) and Status = 2) as errors,
(select count(*) from quote_request_table where convert(varchar, request_date, 103) = convert(varchar, getdate(),103) and Status = 3) as reprint,
(select count(*) from quote_request_table where convert(varchar, request_date, 103) = convert(varchar, getdate(), 103)) as totals
- petter
-
July 18th, 2005, 08:32 AM
#3
Re: How Do I join all this
Thanks very much. Works a treat
If you find my answers helpful, dont forget to rate me 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|