Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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;
 
PREVIOUS NEXT
Tagged: #sql #select #frequent #column
ADD COMMENT
Topic
Name
7+1 =