I was just throwing out some options that came off the top of my head. There 
was no real thought put into optimizing beyond general rushmore rules. 

Do you really need the DISTINCT when the GROUP BY is there? My understanding, 
at least as far as VFP SQL is concerned, is that DISTINCT will force a table 
scan whereas GROUP BY is rushmore optimizable and will use an available index 
tag. 

And as Uncle Ted would say, none of this theoretical stuff matters. You have to 
test with your data to know your stuff is optimized in your environment. :-)

--

rk
-----Original Message-----
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Dave Crozier
Sent: Wednesday, April 16, 2014 11:33 AM
To: profoxt...@leafe.com
Subject: RE: SQL Query

Richard....
More efficient this way if there ate multiple instance records in the compno 
field

Select columns from table 
Where compno not in 
(select distinct compno from table
Where compno='value1' or compno='value2' or...
Group by compno)

Dave


_______________________________________________
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/DF1EEF11E586A64FB54A97F22A8BD04422A746027B@ACKBWDDQH1.artfact.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.

Reply via email to