Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 计数(*)的最大计数_Mysql - Fatal编程技术网

Mysql 计数(*)的最大计数

Mysql 计数(*)的最大计数,mysql,Mysql,我的桌子结构是 | Field | Type | Null | Key | Default | Extra | | uid | char(255) | NO | | | | | lid | char(255) | NO | MUL | | | | ip_address | char(15) | NO |

我的桌子结构是

| 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
order by c desc
limit 1;
这可能会奏效:

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);

这不是即时消息,你不必把每个句子或子句都放在自己的行中。我想你需要
按日期分组(时间戳)
@Bobby是不是
按日期分组
?mysql>选择count(open\u DATE)作为c,day(open\u DATE)作为d->from->link\u click->where->month(open\u DATE)=“01”和year(open\u DATE)=“2011”->按d顺序分组,按c描述限值1;mysql>选择count(open_date)作为c,day(open_date)作为d->from->link_click->where->month(open_date)=“01”和year(open_date)=“2011”->按d分组按c描述限制1排序;你这是什么意思?我检查了一下,发现你的评论与约翰的答案相同。这是否意味着他的答案对你有用?如果是这样,你应该点击他答案左边的大勾号来接受他的答案。
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);