SELECT ASB.SOSEQID, ABSS.ESOSEQID, ABSS.ARAMOUNT, SBO.SACREDITAMOUNT, SBO.ARCLOSEDAY, ASB.WRITERUID, ABSS.ORGID, ASB.USERID, ASB.CUSTID, ASB.ACCTYPEID, ASB.BILLTYPEID, ASB.TIMEWRITTEN, ASB.DEPTID, ASB.BSEQID, ASB.BILLCODE, ASB.ADDRESS, ASB.CONTACTPERSON, ASB.CONTACTPHONE, ASB.TAXNO, ASB.NOTES, ASB.APPLICANT, ASB.TIMESUBMITED, ASB.TIMETERMINATED, ASB.STATEID, ASB.TENANTID, SBS.STATENAME, COUNT(ASBD.ARTID) AS ARTID, SUM(ASBD.AMOUNT) AS AMOUNT FROM T_APP_SALES_BILLING ASB LEFT JOIN T_APP_SALES_BILLING_DETAIL ASBD ON ASB.SOSEQID=ASBD.SOSEQID LEFT JOIN V_APP_B2B_SA_SO ABSS ON ASB.SOSEQID=ABSS.ESOSEQID LEFT JOIN T_SCM_BAS_STATE SBS ON ASB.STATEID=SBS.STATEID LEFT JOIN T_SCM_BSN_ORGCUST SBO ON ASB.CUSTID=SBO.CUSTID GROUP BY ASBD.SOSEQID ORDER BY ASB.SOSEQID DESC 报错:ORA-00979: not a GROUP BY expression
时间: 2024-04-09 21:33:14 浏览: 108
根据你提供的SQL查询语句,出现了ORA-00979错误,该错误是由于GROUP BY表达式的问题引起的。
在GROUP BY子句中,只能包含SELECT列表中列的名称或表达式,而不能包含其他列。在你的查询中,出现了一些不在GROUP BY子句中的列,例如ASB.SOSEQID,ABSS.ESOSEQID等。
要解决这个问题,你需要确保SELECT列表中的列在GROUP BY子句中出现。如果你想选择非聚合列,那么你需要在GROUP BY子句中将它们都包含进去。
以下是修改后的查询语句:
```sql
SELECT
ASB.SOSEQID,
ABSS.ESOSEQID,
ABSS.ARAMOUNT,
SBO.SACREDITAMOUNT,
SBO.ARCLOSEDAY,
ASB.WRITERUID,
ABSS.ORGID,
ASB.USERID,
ASB.CUSTID,
ASB.ACCTYPEID,
ASB.BILLTYPEID,
ASB.TIMEWRITTEN,
ASB.DEPTID,
ASB.BSEQID,
ASB.BILLCODE,
ASB.ADDRESS,
ASB.CONTACTPERSON,
ASB.CONTACTPHONE,
ASB.TAXNO,
ASB.NOTES,
ASB.APPLICANT,
ASB.TIMESUBMITED,
ASB.TIMETERMINATED,
ASB.STATEID,
ASB.TENANTID,
SBS.STATENAME,
COUNT(ASBD.ARTID) AS ARTID,
SUM(ASBD.AMOUNT) AS AMOUNT
FROM T_APP_SALES_BILLING ASB
LEFT JOIN T_APP_SALES_BILLING_DETAIL ASBD ON ASB.SOSEQID=ASBD.SOSEQID
LEFT JOIN V_APP_B2B_SA_SO ABSS ON ASB.SOSEQID=ABSS.ESOSEQID
LEFT JOIN T_SCM_BAS_STATE SBS ON ASB.STATEID=SBS.STATEID
LEFT JOIN T_SCM_BSN_ORGCUST SBO ON ASB.CUSTID=SBO.CUSTID
GROUP BY ASB.SOSEQID, ABSS.ESOSEQID, ABSS.ARAMOUNT, SBO.SACREDITAMOUNT, SBO.ARCLOSEDAY, ASB.WRITERUID, ABSS.ORGID, ASB.USERID, ASB.CUSTID, ASB.ACCTYPEID, ASB.BILLTYPEID, ASB.TIMEWRITTEN, ASB.DEPTID, ASB.BSEQID, ASB.BILLCODE, ASB.ADDRESS, ASB.CONTACTPERSON, ASB.CONTACTPHONE, ASB.TAXNO, ASB.NOTES, ASB.APPLICANT, ASB.TIMESUBMITED, ASB.TIMETERMINATED, ASB.STATEID, ASB.TENANTID, SBS.STATENAME
ORDER BY ASB.SOSEQID DESC;
```
请注意,根据你的业务需求,你可能需要对GROUP BY子句进行相应的调整。
阅读全文