tags:

views:

32

answers:

1
select NV.PHG
From Nhanvien NV
Group by NV.phg
Having count(nv.Manv) >= all (select count(NV.MANV from nhanvien nv group by nv.MANV))

I'm finding a better way to find the 'max count' NV of a PHG ( in this example ) . I think, we meet this case all the time when we do SQL, i should've a better way . Thanks for reading this :)

+2  A: 

To find the group with the largest number of members you can use this:

SELECT TOP(1) phg, COUNT(*) AS count
FROM Nhanvien
GROUP BY phg
ORDER BY COUNT(*) DESC
Mark Byers
Thanks :) . I think about this once but I think there're even a better way than this. Thanks again :)
nXqd