[英]How to edit this mySQL query to not select rows that have same value in 2 columns?
Running the following query I get the following message 运行以下查询我收到以下消息
invalid use of group by 无效使用group by
SELECT COUNT( id ) AS pages,
hash, MIN( DATE( TIMESTAMP ) ) AS FirstVisit,
MAX( DATE( TIMESTAMP ) ) AS LastVisit
FROM behaviour
WHERE MIN( DATE( TIMESTAMP ) ) != MAX( DATE( TIMESTAMP ) )
GROUP BY hash
How can I edit this query so as to not show the rows that FirstVisit equals LastVisit ? 如何编辑此查询以便不显示FirstVisit等于LastVisit的行?
Aggregate function can't be used in
where clause, but can be used in
having`. 聚合函数
can't be used in
where clause, but can be used in
have`中使用。
Try this: 尝试这个:
SELECT
COUNT( id ) AS pages,
hash,
MIN( DATE( TIMESTAMP ) ) AS FirstVisit,
MAX( DATE( TIMESTAMP ) ) AS LastVisit
FROM behaviour
GROUP BY hash
HAVING MIN( DATE( TIMESTAMP ) ) != MAX( DATE( TIMESTAMP ) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.