srdaniel
2008-07-21 21:44:21 UTC
I'm trying to optimize this (paradox) nested select query.
SELECT * FROM table.db C
WHERE C.datetime =
( SELECT MAX( datetime ) from table.db D
WHERE datetime <= ‘07/21/2008’
and d.index1 = c.index1
and d.index2 = c.index2
and d.index3 = c.index3 )
I thought I could simply do something like this (if it is a correct
interpretation of the first query).
SELECT MAX(datetime), field1, ... FROM table.db
Where datetime <= ‘07/21/2008’
GROUP BY field1, ...
However I found that it doesn't work on tables with blob fields as you
can't group by a blob field. So I thought maybe I could just find out
how to re-write it use paradox's QBE language, but we don't have anyone
here with knowledge on that anymore.
Query
table.DB | DateTime | field1 | ...
| Check _max <= "07/21/2008" | Check | ...
EndQuery
However I can't seem to get a conditional MAX to work on a date field.
Is it possible? Does anyone see a better way to write the query?
Using d6, paradox, and yes I know paradox is old and not supported. We
are slowly migrating tables to firebird, these have not yet been.
daniel
SELECT * FROM table.db C
WHERE C.datetime =
( SELECT MAX( datetime ) from table.db D
WHERE datetime <= ‘07/21/2008’
and d.index1 = c.index1
and d.index2 = c.index2
and d.index3 = c.index3 )
I thought I could simply do something like this (if it is a correct
interpretation of the first query).
SELECT MAX(datetime), field1, ... FROM table.db
Where datetime <= ‘07/21/2008’
GROUP BY field1, ...
However I found that it doesn't work on tables with blob fields as you
can't group by a blob field. So I thought maybe I could just find out
how to re-write it use paradox's QBE language, but we don't have anyone
here with knowledge on that anymore.
Query
table.DB | DateTime | field1 | ...
| Check _max <= "07/21/2008" | Check | ...
EndQuery
However I can't seem to get a conditional MAX to work on a date field.
Is it possible? Does anyone see a better way to write the query?
Using d6, paradox, and yes I know paradox is old and not supported. We
are slowly migrating tables to firebird, these have not yet been.
daniel