Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Correlated subquery (?)
Two tables exist. One has a list of data points and attribute IDs by time.
The attribute changes slowly, so a separate table exists holding the
attribute values by attribute ID.
Any attribute will have multiple data points that use the attribute.
I need a query that will return the attribute values for a given range of datapoints.
Select D.Time, A.Attrib1, A.Attrib2, A.Attrib3
from Attributes A, Datapoints D
where (
D.Attribute_ID = A.Attribute_ID and D.Time > Tstart and D.Time < Tend
will not work well enough because it returns lots of D rows; I only need the first D row for each unique Attribute record in the range of Datapoints from Tstart to Tend.
This seems to be a candidate for correlated subqueries but frankly I am
having a difficult time
constructing the appropriate one.
--
Dick Willis, Senior Engineer
Synchrony Industrial Controls, Inc.
rmw_at_synchrony.com
http://www.synchrony.com
Received on Tue Apr 14 1998 - 20:27:13 CDT