~~~~ RT,忙完整理 , ~~
……
--------------
select qc_user_code, count(quality_type) ly
from tbl_qc_paper_dispose tqpd,tbl_qc_paper tqp
group by qc_user_code
having tqp.quality_type like '0' and tqp.id=tqpd.paper_id and tqp.plan_id like '5506C593BF6A4C219FE7B3C242B3530F'----) cfc on
----报错
select qc_user_code, count(quality_type) ly
from tbl_qc_paper_dispose tqpd,tbl_qc_paper tqp
where tqp.quality_type like '0' and tqp.id=tqpd.paper_id and tqp.plan_id like '5506C593BF6A4C219FE7B3C242B3530F'
group by qc_user_code
-----正确查询
--------------
……
1.select 课程号,avg(分数)
from 成绩表
where 课程号='030105' group by 课程号
2.select 课程号,avg(分数)
from 成绩表
where 课程号='030105'
3.select 课程号,avg(分数)
from 成绩表 group by 课程号
having 课程号='030105'
第一种方法是正常做法,第三种多用在having后面有聚合函数的情况下,第二种是第一种的省略形式,不过第二种方法慎用,掌握不好的人会出错误。
select 课程号,avg(分数)
from 成绩表
where 课程号='030105'
如果后面得条件不是 课程号='030105' 而是其他的条件的话,必须加group by 课程号,否则是错误的。