having this database, bold = PK
i need to find the userid with the maximum number of certificates with a SQL query.
Using old plain group by:
select top 1 userid, count(certificatename) total from certificates group by userid -- but not certificatename order by 2 desc --you can use total or count(certificatname) here
Common Table Expressions (CTE) don't add any performance preferences because you need group by in any case.