我的表有3個字段,我想獲得最重複的ticket_id我有裏面,這個查詢工作,但我需要添加一個where子句的「is_winner」,任何幫助?感謝Sqlite查詢最大和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
你怎麼裝?贏家一排?獲取優勝者門票的列表? –