Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Sub-Select syntax not working
Tue, Dec 8 2009 11:50 AMPermanent Link

steve
Hi All,

I have a query that works in both Paradox and Firebird but not in DBISAM.

select *
from testdef td
where td.dbversion = (select max(dbversion) from testdef td2 where td2.testid = td.testid
and td2.language = td.language)

In DBISAM, I get an DBISAM Engine Error # 11949 "SQL parsing error - Expected ) but
instead found max".  What is wrong with this syntax and how would I modify it for DBISAM?

Thanks....
Tue, Dec 8 2009 3:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Steve,

<< In DBISAM, I get an DBISAM Engine Error # 11949 "SQL parsing error -
Expected ) but instead found max".  What is wrong with this syntax and how
would I modify it for DBISAM? >>

DBISAM does not support using sub-queries as scalar values.   To get what
you want, use this script:

select testid, language, max(dbversion) as MaxVersion
into '\memory\temp'
from testdef
GROUP BY testid, language;

select td.*
from testdef td INNER JOIN '\memory\temp' ON td.testid = temp.testid and
td.language = temp.language and td.dbversion=MaxVersion

--
Tim Young
Elevate Software
www.elevatesoft.com
Image