Get highest percentage value from a column based on value from another column in mySQL -


i have query percentages of different values in specific column:

select dma, count(*) / const.cnt *100 my_percent  full_db3 cross join  (select count(*) cnt full_db3) const group dma order my_percent desc limit 10; 

step one: need amend gives me top 10 values in column dma based on value of column. example, if value in column gender "f", top 10 values in column dma. (which doesn't work, of course).

select dma, count(*) gender = 'female' / const.cnt *100 my_percent  full_db3 cross join  (select count(*) cnt full_db3) const group dma order my_percent desc limit 10; 

the above throws error, should point across.

step 2 looping through columns , returning top 10 values in every column (not dma) give value of specific column (e.g., gender= 'female'). what's best way this?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -