SELECT a.uid,a.name,b.did,b.gid FROM USER AS a,usrdata AS b WHERE b.uid=a.uid AND b.gid IN (22,23) GROUP BY a.name
这个在mysql 测试成功,但到oracle 不行,
[SQL] SELECT a.TEMPNAME,b.FYFB,a.TEMPID,b.TEMPID FROM TEMPADD AS a, TPTYPE AS b WHERE b.TEMPID=a.TEMPID AND b.FYFB IN(161)
[Err] ORA-00933: SQL command not properly ended
------最佳解决方案--------------------------------------------------------
SELECT a.uid,a.name,b.did,b.gid FROM USER AS a,usrdata AS b WHERE b.uid=a.uid AND b.gid IN (22,23) GROUP BY a.uid,a.name,b.did,b.gid
Oracle中用到GROUP BY时、所有查询的字段(除统计函数、聚合函数外)都必须全部进行分组。
------其他解决方案--------------------------------------------------------
查询统计数量:
SELECT count(*) FROM USER AS a,usrdata AS b WHERE b.uid=a.uid AND b.gid IN (22,23) GROUP BY a.uid,a.name,b.did,b.gid
------其他解决方案--------------------------------------------------------
oracle 的group by必须有统计函数才能够分组
如:
select a,sum(b) from y group by a
------其他解决方案--------------------------------------------------------
还有个补充问题,我要统计SELECT COUNT(*) 上面这条语句有多少记录,要怎么写呀,新手,谢谢
------其他解决方案--------------------------------------------------------
统计的,不对!
------其他解决方案--------------------------------------------------------
问题自己解决了,主要还是 GROUP BY 如果是多表查询,这里只能写,要显示的那个表的字段,如果,都出现,就会有重复记录!