0
We are running the SELECT below in order to deliver a percentage difference between the somatic values PRECO_UNITION and PRECO_TABELA. We try to do this in the simplest way by performing the common division within SELECT and assigning DIFERENCA_PERCENTUAL, but Sql Developer delivers the following error:
ORA-00904: "DIFERENCA_PERCENTUAL": identificador inválido
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Erro na linha: 14 Coluna: 68
Below is the SELECT we are running on SQL Developer:
SELECT
FAITEMPE.NF NOTA_FISCAL,
FAITEMPE.CD_EMPRESA COD_CLIENTE,
GEEMPRES.NOME_COMPLETO NOME_CLIENTE,
SUM(FAITEMPE.PR_UNITARIO) AS PRECO_UNITARIO,
SUM(FAITEMPE.PR_ORIGINAL) AS PRECO_TABELA,
(PR_UNITARIO / PR_ORIGINAL) AS DIFERENCA_PERCENTUAL
FROM FAITEMPE, GEEMPRES
WHERE FAITEMPE.CD_EMPRESA = GEEMPRES.CD_EMPRESA
AND FAITEMPE.DT_ITEM BETWEEN TO_DATE(:data_inicial, 'DD/MM/YYYY') AND TO_DATE(:data_final, 'DD/MM/YYYY')
AND FAITEMPE.CONTROLE LIKE '16'
GROUP BY FAITEMPE.NF, FAITEMPE.CD_EMPRESA, GEEMPRES.NOME_COMPLETO, DIFERENCA_PERCENTUAL
We also forward the result of the simple query before incrementing this DIFERENCA_PERCENTUAL:
Any better suggestions on how we can extract this information???
( SUM(FAITEMPE.PR_UNITARIO) /SUM(FAITEMPE.PR_ORIGINAL) as
– Motta
@Motta worked well here. Thanks man!
– Adair Juneo