I tried to run below query on oracle database
select distinct LABEL,EVENT_DATETIME,USL,LSL from
(select eventTbl.LABEL,eventTbl.EVENT_DATETIME,limitTbl.USL,limitTbl.LSL from EVENT_TABLE eventTbl
INNER JOIN LIMITS_TABLE limitTbl on limitTbl.start_date <= eventTbl.EVENT_DATETIME
AND limitTbl.end_date >= eventTbl.EVENT_DATETIME where eventTbl.plant_id = 'plant1')
That gives the below error:
ORA-00904: "LIMITTBL"."LSL": invalid identifier
- 00000 - "%s: invalid identifier"
The DDL of LIMITTBL table is
create table LIMITS_TABLE(
plant_id varchar2(80),
start_date date,
end_date date,
USL number(11,5),
LSL number(11,5)
);
This is too much code to put into a comment; if columns really existed, your code would have worked:
However, as I commented - if you enclosed column names into double quotes and used lower/mixed letter case, query would have failed; see line #5:
If that's the case, you'll have to use double quotes and the same letter case every time you reference that column (lines #7, 8, 13, 14):