我的表结构是
| 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);
但结果是空集。
PLS。建议。
答案 0 :(得分:3)
这就是你想要的吗?
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;
答案 1 :(得分:0)
这可能有效:
select * from (
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);