假设我正在尝试从本月开始查找一家商店销售的前 10 种冰淇淋口味。然而,我目前的查询只给了我 7/01 的前十种口味
select *
from buy_history
where date > '2012-07-01 00:00:00'
group by flavor
order by max(purchase_count) desc
limit 10;
(是的,显然每毫秒可以购买多个冰淇淋。)
桌子看起来像
buy_history(id, flavor, date, purchase_count)