SELECT id HAVING maximum count of id

后端 未结 4 590
暖寄归人
暖寄归人 2020-12-15 22:39

Have a products table with item_id and color_id. I\'m trying to get the color_id with the most non-null instances.

This fails:

SELECT color_id 
           


        
4条回答
  •  攒了一身酷
    2020-12-15 23:18

    To make it simple, use in built function in Oracle(Works only with Oracle Database 11g+ version) :

    select stats_mode(color_id) from so_test 
    

    This would return highest occurrence of colour ids.

提交回复
热议问题