我的表结构是
| Field | Type | Null | Key | Default | Extra |
| uid | char(255) | NO | | | |
| lid | char(255) | NO | MUL | | |
| ip_address | char(15) | NO | | | |
| user_agent | char(255) | YES | | NULL | |
| open_date | timestamp | NO | MUL | CURRENT_TIMESTAMP | |
| referrer | char(255) | YES | | NULL | |
| environ | text | YES | | NULL | |
| country | char(255) | NO | MUL | | |
我想查询在一个月的特定日期记录的最大点击次数
查询
select count(open_date) as c,day(open_date) as d
from link_click
where month(open_date)="01" and year(open_date)="2011"
group by d
having c =MAX(c);
但结果是空集。
请。建议。
最佳答案
这就是你想要的吗?
select count(open_date) as c,day(open_date) as d
from link_click
where month(open_date)="01" and year(open_date)="2011"
group by d
order by c desc
limit 1;
关于mysql - count(*) 的最大计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4955326/