Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Correlated subquery (?)

Re: Correlated subquery (?)

From: BobH <b-horton_at_worldnet.att.net>
Date: Tue, 14 Apr 1998 23:06:24 -0400
Message-ID: <6h189b$9ap@bgtnsc03.worldnet.att.net>


Dick Willis wrote:
>
> 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

Try adding DISTINCT after the SELECT Received on Tue Apr 14 1998 - 22:06:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US