1
I have a select that is giving error. The idea is the result show five columns (CODPROD, DESCRPROD, CODLOCAL, DESCRLOCAL, STOCK). I’m extracting four tables (TGFEST, TGFPRO, TGFLOC and TGFGRU) and the Stock column should be added because the tables bring the same product several times with different stock in each line. Thus the objective is to show a product per line with the sum of the stock of this product. In this case I am filtering by a specific location type (EST.CODLOCAL).
Follows the code:
SELECT
PRO.DESCRPROD AS Produto,
SUM(ESTOQUE) AS Estoque,
EST.CODPROD,
EST.CODLOCAL,
LOC.DESCRLOCAL
FROM TGFEST EST
INNER JOIN TGFPRO PRO ON (EST.CODPROD=PRO.CODPROD)
INNER JOIN TGFLOC LOC ON (EST.CODLOCAL=LOC.CODLOCAL)
INNER JOIN TGFGRU GRU ON (PRO.CODGRUPOPROD=GRU.CODGRUPOPROD)
WHERE EST.CODLOCAL='1010000'
GROUP BY
PRO.DESCRPROD,
EST.CODPROD
ORDER BY PRO.DESCRPROD
Follows error: ORA-00979: not a GROUP BY expression
If anyone can help, Mario
In Oracle the group by must contain all select columns (apart from aggregators).
– Motta
@Motta grateful for the clarification that was fundamental for me to have managed to finish my activity. Thank you!
– user236650