Re: select most common value



SELECT TOP 5 WITH TIES col
FROM YourTable
GROUP BY col
ORDER BY COUNT(*) DESC

--
David Portas
SQL Server MVP
--


.



Relevant Pages

  • Re: Query question?
    ... Better specs would help us with future questions. ... David Portas ... SQL Server MVP ... Prev by Date: ...
    (microsoft.public.sqlserver)
  • Re: SQL 2000, SP3a "TOP 100%"
    ... The best place to use ORDER BY is when you query the view. ... David Portas ... SQL Server MVP ... Prev by Date: ...
    (microsoft.public.sqlserver)
  • Re: Price of SQL Server
    ... Workgroup Edition ... David Portas ... SQL Server MVP ... Prev by Date: ...
    (microsoft.public.sqlserver.setup)
  • Re: datafile and log file on cluster
    ... files on separate physical disks. ... David Portas ... SQL Server MVP ... Prev by Date: ...
    (microsoft.public.sqlserver.setup)
  • Re: How to connect to a dedicated m/c
    ... Windows 2003. ... David Portas ... SQL Server MVP ... Prev by Date: ...
    (microsoft.public.sqlserver.connect)