case function with row count

  • hi

    pls give me eg for case function with row count

    eg: if the row count is >1 then HIGH <1 or zero low

    ---these r table and column for refernce--

    DECLARE

    @rc tinyint ,

    @var varchar(50)

    set @var = (SELECT emd.tpa_id

    from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD

    where emd.tpa_id=ed.tpa_id

    and

    emd.empe_key=ed.division_key)

    thanxs

    india-bangalore

  • select mycol, case when myrowcountcol > 1 then 'High' 

                              when myrowcountcol < 1 then 'Low' 

                              else 'ONE'

                              end as HL

    from (select mycol, count(*) as myrowcountcol

              from ..... 

             group by mycol

            ) A

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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