Hello All,
This is an example of a query I am opening as ref_cursor in a stored procedure that runs on an Oracle 9i box.
the structure of the tables are;
readings (approx >100 million records, index spid,dateofread)
spid varchar2
dateofread date
value NUMBER
edval varchar2
met_driect (approx >100,000 records, index area)
area varchar2
spid varchar2
There is a one to many relationship between met_direct.spid=readings.spid.
I run the following query to reurn the last date when all the spids for a given area in met_direct have a record in the readings table.
SELECT MAX(dateofread) FROM (SELECT dateofread FROM (SELECT dateofread FROM READINGS
WHERE
SPID IN (SELECT SPID FROM met_direct WHERE area_id='54802' GROUP BY spid))
GROUP BY dateofread
HAVING COUNT(*)=
(SELECT COUNT(*) FROM met_direct WHERE area_id='54802'));
Is there a better way of constructing the above query to return this date?
Any help much appreciated.
Gareth
This is an example of a query I am opening as ref_cursor in a stored procedure that runs on an Oracle 9i box.
the structure of the tables are;
readings (approx >100 million records, index spid,dateofread)
spid varchar2
dateofread date
value NUMBER
edval varchar2
met_driect (approx >100,000 records, index area)
area varchar2
spid varchar2
There is a one to many relationship between met_direct.spid=readings.spid.
I run the following query to reurn the last date when all the spids for a given area in met_direct have a record in the readings table.
SELECT MAX(dateofread) FROM (SELECT dateofread FROM (SELECT dateofread FROM READINGS
WHERE
SPID IN (SELECT SPID FROM met_direct WHERE area_id='54802' GROUP BY spid))
GROUP BY dateofread
HAVING COUNT(*)=
(SELECT COUNT(*) FROM met_direct WHERE area_id='54802'));
Is there a better way of constructing the above query to return this date?
Any help much appreciated.
Gareth