Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql select most frequent value in column

SELECT col, COUNT(col) AS value_occurrence
FROM m_table GROUP BY col ORDER BY value_occurrence DESC LIMIT 1;

-- Oracle <= 11g
SELECT * FROM (SELECT col, COUNT(col) AS value_occurrence
FROM m_table GROUP BY col ORDER BY value_occurrence DESC)
WHERE rownum = 1;
Comment

PREVIOUS NEXT
Code Example
Sql :: sqlite version check 
Sql :: sql replace null with 0 
Sql :: view linked servers sql 
Sql :: transalations from sql to Linq count and group by 
Sql :: get first 3 letters in sql 
Sql :: Configure MYSQL to run on another port number, other than the default port 3306 ubuntu linux 
Sql :: what is initial catalog in sql connection string 
Sql :: mysql one week ago 
Sql :: oracle new column 
Sql :: sous requete sql 
Sql :: backup ms sql database table data to file 
Sql :: UPDATE if else mysql 
Sql :: select tables from mysql database 
Sql :: access mysql command mac xampp 
Sql :: find difference in dates sql 
Sql :: show processlist mysql full query 
Sql :: sQL query to get all table records count from a database 
Sql :: sql random number between 1000 and 9999 
Sql :: ora-02391 
Sql :: array out of range mql4 
Sql :: random record using order by rand() mysql 
Sql :: oracle invalid table name 
Sql :: postgresql default value boolean 
Sql :: vacuum table postgres 
Sql :: postgres group by 10 minute intervals 
Sql :: mysql check if not null 
Sql :: input in mysql 
Sql :: get name of day in sql 
Sql :: mysql change auto_increment start value 
Sql :: sql server select value large text 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =