mysql - count(*) 的最大计数

标签 mysql

我的表结构是

| 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/

相关文章:

mysql - 左连接最新记录(如果存在)

php - 使用 Inner Join MySQL php 从 3 个表中获取数据

mysql - MySQL 中 BIT(64) 列的奇怪行为

php - 我的术语已被搜索,但我的 OR 语句没有收到任何结果

mysql - Zend 框架中的 "SQLSTATE[HY000]: General error"

php - 根据从数据库中提取的数据创建变量

mysql - 过滤掉子查询列的结果

c# - 从 C# 应用程序文本框将值插入 MySQL 数据库

php - 当他们使用电子邮件登录时从表中获取用户名

java - 没有这样的方法错误: