find the percentage of two column value with grouping records

  • You could use CTE's

    Something like

    ;

    WITH cte1 as

    (

    select zone, count([incident id]) as cnt1

    from incident_detail

    group by zone

    ), cte2 as

    (

    select zone, count([incident id]) as cnt2

    from incident_detail

    where [slm status]='All Service Targets

    )

    select cte1.zone, (cte2.cnt2 + 0.00) /cte1.cnt1

    from cte1

    inner join cte2 on cte1.zone=cte2.zone

    If that's not what you're looking for please provide table definition (DDL script) ready to use sample data and expected result as described in the first link in my signature.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing post 1 (of 2 total)

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