How to determine most often element in postgreSQL? -


if have column similar this:

2012 2013 2012 2012 2011 

how determine year more used others? (in example 2012, since there 3 entries year).

one way calculate numbers of occurences elements
order them number in descending order, , take first one:

select element table1 group element order count(*) desc limit 1 ; 

demo: http://sqlfiddle.com/#!15/47e59/2


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -