How to add condition to my group count statement

  • When I run this query it gives me the group name of the Type and the count correctly. There is also a group name "Null" with correct number of counts. How do I take that count number from the group "Null" and add it to the one that has a group name that is specified by me. Here is the initial query

    Select Count(t.TicketID) AS [Number of Tickets], T.Type
    From Tickets T
    Group by Type

    # of Tickets Type
    24 -------------- Order
    10---------------- product
    5----------------- Null

    I want to add 5 to the "Order" .So this is what I want to see

    # Tickets Type
    29---------------- Order
    10----------------- product

  • Just put an ISNULL around Type

    Select Count(t.TicketID) AS [Number of Tickets], ISNULL(T.Type, 'Order')
    From Tickets T
    Group by ISNULL(T.Type, 'Order')

  • Excellent..Thank you!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply