2
Good afternoon, I have a question regarding the use of AS in plsql in an oracle database
follows the code:
SELECT CC.NOME, SUM(1) AS QTD_CEL, SUM(CASE WHEN C.STATUS LIKE 'INATIVO' THEN 1 ELSE NULL END) AS QTD_INATIVO , MIN(C.NEW_COL) AS DATA
FROM TB_CLIENTE CC, TB_CONTRATO C
WHERE C.ID_CLIENTE=CC.ID_CLIENTE
AND QTD_CEL > 1
AND CC.SEGMENTO='EMPRESARIAL'
AND (C.ID_PRODUTO = 304
OR C.ID_PRODUTO = 305)
GROUP BY CC.NOME
and I’m getting the following error:
ORA-00904: "QTD_CEL": identificador inválido
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Erro na linha: 42 Coluna: 5
Apparently he doesn’t identify the ALIAS as an identifier, someone could help me?
AND QTD_CEL > 1 exchange for a "having" https://www.oracletutorial.com/oracle-basics/oracle-having/
– Motta
This answers your question? Error Case and Group by - Oracle SQL Developer
– Pedro Sanção