SELECT COMPANY.STATE, COUNT(BILLS.NAME), SUM(BILLS.AMOUNT) FROM BILLS, COMPANYGROUP by COMPANY.STATE having COMPANY.NAME = BILLS.NAME;
我就不知道哪里错了,group by在select里面的字段必须有,但是全加上去了还是不行,何解?
SELECT COMPANY.STATE, COUNT(BILLS.NAME), SUM(BILLS.AMOUNT) FROM BILLS, COMPANY
WHERE COMPANY.NAME = BILLS.NAME GROUP BY COMPANY.STATE;
where 改为 on
追问SELECT COMPANY.STATE, COUNT(BILLS.NAME), SUM(BILLS.AMOUNT) FROM BILLS JOIN COMPANY
COMPANY.NAME = BILLS.NAME GROUP by COMPANY.STATE
不对
oracle12c:SQL 错误: ORA-00979: 不是 GROUP BY 表达式
having后面的东西换成where写吧,having我记得写的是组过滤的条件,我觉得你应该是要先连接查询,再分组,如果分组后还需要过滤就写having子句,如果不需要就不写having子句 SELECT COMPANY.STATE, COUNT(BILLS.NAME), SUM(BILLS.AMOUNT) FROM BILLS, COMPANY where COMPANY.NAME = BILLS.NAME GROUP by ...