postgresql - Finding top searched country and ip from a table -
i have table "user" columns ip,os,country , browser. want find ip,os,country , browser maximum count.is there query in postgresql
the current query i'm using is
select * ( select count(ip),ip user group ip  union select count(os),os user group os  union select count(country),country user group country  union select count(browser),browser user group browser ) user  it shows ip,os,country , browser , count want column name max count of column
is possible in single query?
im expecting this
os      count           ip              count linux     50         xx:xx:xx:xx      95 
select *   (select count(ip) cnt_ip, ip user group ip order 1 desc limit 1) t_ip,   (select count(os) cnt_os, os user group os order 1 desc limit 1) t_os,   (select count(country) cnt_country, country user group country order 1 desc limit 1) t_country,   (select count(browser) cnt_browser, browser user group browser order 1 desc limit 1) t_browser 
Comments
Post a Comment