Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.31 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Most frequently occurring values in MySQL database
  2. SELECT num, COUNT(num) AS ct
  3. FROM yourtable
  4. GROUP BY num
  5. ORDER BY ct DESC
  6.        
  7. 1, 1, 3, 1, 1, 17, 12, 1, 3, 17, 3
  8.        
  9. num  | ct
  10. ============
  11.      1  |  5
  12.      3  |  3
  13.     17  |  2
  14.     12  |  1
  15.        
  16. SELECT num, COUNT(num) AS occurrence
  17. FROM table
  18. GROUP BY num