当我分组条目时,我试图从列中获取最常用的值。我想我得用一个 GROUP BY
为了让它工作。我有以下疑问:
SELECT post_id, (SELECT browser from visits WHERE
id = ? GROUP BY browser ORDER BY count(browser)
DESC limit 1) as common_browser, count(id) as visits FROM `visits` group by post_id
在“?”上,我想传递组的id,如果我向它传递一个参数,它将执行我尝试执行的操作,即: id = 1
. 如果有任何其他方法来完成这一点,请让我知道!
1条答案
按热度按时间ioekq8ef1#
使用相关子查询。