我的表有 3 个字段,我想得到我里面重复次数最多的ticket_id,这个查询有效,但我需要在“is_winner”上添加一个 where 子句,有什么帮助吗?谢谢
ID TICKET_ID IS_WINNER
1 2 1
2 3 1
3 2 1
4 3 0
5 2 1
6 2 0
7 3 0
8 2 1
9 2 0
select query1.* FROM (Select ticket_id, Count(*) As order_count
FROM ticket_log
GROUP BY ticket_log.ticket_id) query1,(Select Max(query2.order_count) As highest_count
FROM (Select ticket_id, Count(*) As order_count
FROM ticket_log
GROUP BY ticket_log.ticket_id) query2) query3 where query1.order_count = query3.highest_count