How to achieve this?

  • Hi Guys,

    can anybody tell me the exact query for the following in sql server 2005?

    The following is my table:

    PatIDAgeGender

    132F

    225M

    320F

    418M

    And i need the output like the following:

    Total_Count Persons_above_25No_of_Male whose age>25

    4 2 1

    Thanks & Regards,
    Shriram.

  • SELECT COUNT(*) AS Total

    , SUM(CASE WHEN Age >= 25 THEN 1 ELSE 0 END) AS CntAge25AndOver

    , SUM(CASE WHEN Sx = 'M' THEN 1 ELSE 0 END) AS CntMales

    FROM dbo.Table

  • Thank you very much ninja 🙂

    Thanks & Regards,
    Shriram.

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

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