I have a table OrderUser
UserName | OrderNo
-----------------------
User1 | 1
User1 | 2
User1 | 3
User2 | 4
User2 | 5
I need the only the userID
with min rows, meaning user2
in this case.
Simple T-Sql statement is required because I will use the code in a SqlCommand
in C#.
Please help.
SELECT TOP 1 UserName, COUNT(*)
FROM myTable
GROUP BY UserName
ORDER BY COUNT(*) ASC
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments