Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to get the following output

$
0
0
i have a table emp with records as follows:

empname        highprtjobs

tsaliki             h1
sasi                h2
Srinivas           h3       
tsaliki              h4
sasi                 h5


in this i wrote  a select statement as follows:

select empname,count(highprtjobs)as noofhighprtjobs from testemp group by empname. i got the result as 

empname  noofhighprtjobs
sasi                2
srinivas        1
tsaliki         2


In this now i am trying to get the one which is having min noofhighprtjobs. So i wrote the above statement but it is throwing some error.So how do i get the empname whose noofhighprtjobs is minimum.




select empname,count(highprtjobs)as noofhighprtjobs from testemp group by empname
having min(count(highprtjobs))

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>