Problem with getting the count of records when using group by and having

  • Hello All,

    I have the below query returning the result set. I just want to get the total records returned by the query. But iam not able to get the count. Please let me know how can we achieve this. Iam running this query in a function.

    select count(MclId) from vDCRDoctordetails

    where LocationId=121 and month(DcrDate)=4 and year(DcrDate)=2011

    and UserId=121 group by MclId having count(MCLId)=1

    Thanks,

    Vijay

  • SELECT COUNT (*) FROM (

    select MclId from vDCRDoctordetails

    where LocationId=121 and month(DcrDate)=4 and year(DcrDate)=2011

    and UserId=121 group by MclId having count(MCLId)=1

    ) dtGrpBy

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

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