Another SQL question folks....  this time about correlated subqueries (i
think), I have the following SQL (that doesn't work):

                SELECT DISTINCT
                        ID.Point, ID.DateTimeAdded, P.ConfigurationID
                FROM
                        ImportData ID, PointAttributes P
                WHERE
                        ID.Point = P.Point AND
                        ConfigurationID =
                        (
                                SELECT
                                        ConfigurationID
                                FROM
                                        Configuration
                                WHERE
                                        StartDate =
                                        (
                                                SELECT
                                                        MAX(StartDate)
                                                FROM
                                                        Configuration
                                                WHERE
                                                        StartDate <=
ID.DateTimeAdded
                                        )
                         )

The problem that I'm having is that at the end, in the "WHERE StartDate <=
ID.DateTimeAdded" the ID.DateTimeAdded field isn't getting filled in.  If I
hard code the date everything is fine thou (or thou the wrong results are
returned).

The desired result is to rurned the P.ConfigurationID that starts just prior
to ID.DateTimeAdded along with the ID.Point and ID.ConfigurationID.

The query runs without error, but returns an empty result set.  Am I wrong?
Or does the BDE (Local SQL/Paradox) not support this type of query?

(It's times like this I wish I really knew SQL!)

Mark



-- 
Mark Derricutt                     | Chalice of Blood
Software Developer                 | New Zealand Christian Music News
Auckland, New Zealand              | http://www.chalice.gen.nz
[EMAIL PROTECTED]                | UIN: 1934853

Getting jiggy with Days of the New - Days of the New


---------------------------------------------------------------------------
  New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to