0

I got error

Warning: oci_execute() [function.oci-execute]: ORA-00979: not a GROUP BY expression in

My SQL syntax :

SELECT
M.MODEL_NO,
M.MODEL_NAME,
P.FORM_NO,
P.MODEL_NO,

TO_CHAR(TO_DATE(P.DATE_ADDED,'YYYY-MM-DD'),'MONTH'),
Q.FORM_NO,
Q.STATUS_QTY,
SUM(Q.QTY) OVER (PARTITION BY P.FORM_NO ORDER BY P.FORM_NO
RANGE UNBOUNDED PRECEDING) QTY

FROM
SEIAPPS_MODEL M, SEIAPPS_PRODUCTION_STATUS P, SEIAPPS_QTY Q

WHERE
P.FORM_NO = Q.FORM_NO AND P.MODEL_NO = M.MODEL_NO AND M.MODEL_NO = '$model_no' AND P.DATE_ADDED LIKE '$years-09%' AND Q.STATUS_QTY = 'OK' GROUP BY M.MODEL_NAME

I got this error because I add GROUP BY M.MODEL_NAME. I need to group it by MODEL_NAME. Please help.

Thanks

Asean Jazz
  • 115
  • 1
  • 2
  • 14

1 Answers1

0

In sql server your query would generate a group by related error, because not all the non-aggregated columns appear in the group by clause.

Accordingly I expect that your problem will go away once you either:

a) add the other non-aggregated columns into the group by clause, or b) restructure your logic to build (1) a query with just model_name and the aggregated data which is then joined to (2) a query providing all the other data you want in your result set.

John Bingham
  • 1,996
  • 1
  • 12
  • 15