我有一个问题,我正在寻找重复的用户ID并需要2个where子句。不幸的是,下面的查询给我一个错误。如何根据我想要的标准查看重复的用户ID?
select user_id,
order_placed,
downloaded,
template
from orders
GROUP BY
user_id,
order_placed,
downloaded,
template
where (modified >= '2014-01-01' and downloaded = 'N' )
HAVING count(*) > 1
答案 0 :(得分:0)
在WHERE
之后 GROUP BY
之前放置FROM
。
SELECT user_id,
order_placed,
downloaded,
template,
COUNT(*)
FROM orders
WHERE ( modified >= '2014-01-01'
and downloaded = 'N' )
GROUP BY
user_id,
order_placed,
downloaded,
template
HAVING count(*) > 1;