That will work, but you can do the same thing more efficiently without
the union. Try this! :)
SELECT ConfigurationID, StartDate
FROM Configuration
WHERE StartDate BETWEEN (
SELECT Max(StartDate)
FROM Configuration
WHERE StartDate < (
SELECT Min(DateTimeAdded)
FROM ImportData)
)
AND (
SELECT Max(DateTimeAdded)
FROM ImportData)
ORDER BY StartDate
Cheers,
Carl Reynolds Ph: +64-9-4154790
CJN Technologies Ltd. Fax: +64-9-4154791
[EMAIL PROTECTED] DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
> -----Original Message-----
> From: Derricutt, Mark [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, October 01, 1999 5:31 PM
> To: Multiple recipients of list database
> Subject: RE: [DUG-DB]: SELECT FIRST/LAST ... again
>
> > Are you only looking for the single, most recent
> > Configuration that existed before the first DateTimeAdded in
> > ImportData?
>
> Close, you gave me a pointer thou :-) I was wanting ALL
> configuration's
> that were active in ImportData, the final SQL I used (using a JOIN
> was:
>
> SELECT
> ConfigurationID, StartDate
> FROM
> Configuration C
> WHERE
> C.StartDate
> BETWEEN
> (
> SELECT
> MIN(DateTimeAdded)
> FROM
> ImportData
> ) AND (
> SELECT
> MAX(DateTimeAdded)
> FROM
> ImportData
> )
> UNION SELECT
> ConfigurationID, StartDate
> FROM
> Configuration
> WHERE
> StartDate =
> (
> SELECT
> MAX(StartDate)
> FROM
> Configuration
> WHERE
> StartDate < ( SELECT MIN(DateTimeAdded) FROM ImportData )
> )
> ORDER BY
> StartDate
>
>
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Database List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
application/ms-tnef