Gene, Have you tried bracketing the statement off: where; (cwkt.clcode=ctwc.clcode) ; and (cwkt.wccode=ctwc.wccode) ; and( cwkt.trndate between ctwc.validfr and ctwc.validto);
Dave -----Original Message----- From: ProFox [mailto:profox-boun...@leafe.com] On Behalf Of Gene Wirchenko Sent: 08 August 2017 01:36 To: ProFox Email List <profox@leafe.com> Subject: SQL Error Hello: The following statement throws "SQL: Error correlating fields.": select *; from cwkt; where; funccode="TW" and trndate>={^2017.07.01} and; exists; (; select .t. from ctwc; where; cwkt.clcode=ctwc.clcode and cwkt.wccode=ctwc.wccode and; cwkt.trndate between ctwc.validfr and ctwc.validto; ); order by clcode,wonbr,trndate This statement works: select *; from cwkt; where; funccode="TW" and trndate>={^2017.07.01} and; exists; (; select .t. from ctwc; where; cwkt.clcode=ctwc.clcode and cwkt.wccode=ctwc.wccode and; cwkt.trndate>=ctwc.validfr and cwkt.trndate<=ctwc.validto; ); order by clcode,wonbr,trndate The only difference is the second line of the nested select's where expression. The first uses between, and the second uses >= and <=. What am I missing? Sincerely, Gene Wirchenko [excessive quoting removed by server] _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/18725b8cd2d5d247873a2baf401d4ab2b478a...@ex2010-a-fpl.fpl.LOCAL ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.