I’m putting together a query which references a table via an alias on numerous occasions, but it then proceeds to state:
*ORA-00904: “MPAN_STATUS”.”MPANCORE”: invalid identifier
00904. 00000 – “%s: invalid identifier”
*Cause:
Action:
Error at Line: 43 Column: 126
The query is as follows:
SELECT readings.mpancore, mtds.meterid, (SELECT CASE
WHEN meter_type
LIKE 'RCAM%' AND
retrieval_method = 'R'
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.mtds
WHERE meter_removed IS NULL) "IS_SMART",
(SELECT CASE
WHEN flowversion = 'D0010' AND
readings.filename IS NOT NULL AND
readings.filedate >= mpan_status.ssd
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.readings, edmgr.mpan_status
WHERE readings.mpancore = mpan_status.mpancore) "D0010_RECEIVED",
(SELECT CASE
WHEN effective_from_date >= mpan_status.ssd AND
dc_id = mpan_status.confirmed_dc_id
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.D0019_reg, edmgr.mpan_status) "D0019_RECEIVED",
(SELECT CASE
WHEN file_date_time <= SYSDATE-409
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.D0019_reg) "RF_READ",
(SELECT CASE
WHEN file_date_time <= SYSDATE-220
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.D0019_reg) "R3_READ",
(SELECT CASE
WHEN file_date_time <= SYSDATE-118
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.D0019_reg) "R2_READ",
(SELECT CASE
WHEN file_date_time <= SYSDATE-56
THEN 'TRUE'
ELSE 'FALSE' END
FROM edmgr.D0019_reg) "R1_READ"
FROM edmgr.mpan_status "mpan_status" LEFT JOIN edmgr.D0019_reg "D0019" ON mpan_status.mpancore = D0019.metering_system_id
LEFT JOIN edmgr.readings "readings" ON mpan_status.mpancore = readings.mpancore
LEFT JOIN edmgr.mtds "mtds" ON readings.mpancore = mtds.mpancore
AND D0019.metering_system_id = mtds.mpancore
AND mtds.meterid = readings.meterid
I’m a complete novice really, so any assistance would be greatly appreciated.
Let’s start off defining the ORA-00904 error:
Also it would be a case-sensitivity issue (where you put mpan_status in quotes, in the FROM argument.) In Oracle, column names are case-sensitive only when you put them in quotes.
EDIT:
Here’s a suggestion of I would write the query (avoiding the use of ANSI joins, and subqueries).