CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    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

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    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

  3. #3
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    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
  •  





Click Here to Expand Forum to Full Width

Featured