Answers:
试试这个;
select gid
from `gd`
group by gid
having count(*) > 10
order by lastupdated desc
AND ((stock = 1 OR quantity > 0) OR (COUNT(v.id) > 0)
HAVING variations > 0 OR (stock = 1 OR quantity > 0)
SELECT COUNT(*)
FROM `gd`
GROUP BY gid
HAVING COUNT(gid) > 10
ORDER BY lastupdated DESC;
编辑(如果您只想要这些小物品):
SELECT MIN(gid)
FROM `gd`
GROUP BY gid
HAVING COUNT(gid) > 10
ORDER BY lastupdated DESC
仅有条款的学术版本:
select *
from (
select gid, count(*) as tmpcount from gd group by gid
) as tmp
where tmpcount > 10;
我想你不能添加count()
使用where
。现在看看为什么....
where
不相同having
,having
表示您正在从事小组工作或从事同等的工作,它也涉及整个小组,
现在如何计算整个团队
创建一个表并输入一些ID,然后使用:
select count(*) from table_name
您会发现总值意味着它表示某个组!所以where
不添加count()
;
COUNT(*)只能与HAVING一起使用,并且必须在GROUP BY语句之后使用。请找到以下示例:
SELECT COUNT(*), M_Director.PID FROM Movie
INNER JOIN M_Director ON Movie.MID = M_Director.MID
GROUP BY M_Director.PID
HAVING COUNT(*) > 10
ORDER BY COUNT(*) ASC