Hi Tristan > Message: 9 > Date: Wed, 20 Jun 2007 14:20:26 +0100 > From: "Tristan Leask" <[EMAIL PROTECTED]> > Subject: Select statement with a max() of 2 values > To: [EMAIL PROTECTED] > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="us-ascii" > > Afternoon all, > > I have got a strange one here. I have written a SELECT statement which > is something similar to.... > > SELECT f1, f2, max(f5,f6) as test FROM t1...... > > This looks ok to me, however when I try to run it, foxpro doesn't like > the fact that I am using the MAX() function. Apparently when MAX() is > used in a SELECT statement it wants to calculate the maximum of the > specified column. Thus can you not use MAX() to calculate the maximum > of some fields in a row, E.g. MAX(f1, f2, f3, f4)? > > Thanks
This is one of the reasons I recommend people not mix VFP syntax with SQL syntax in VFP SQL. Use BETWEEN instead of BETWEEN() etc. If there is no exact match then get as close as possible. This IMO aids us in switching between the VFP and SQL Server without stubbing our toes. :) A UDF called from a SQL can be really slow. Try to avoid them. Since you're just using two variables, the closest VFP9 match I can get to SQL Server is pre VFP9 select iif(f5>f6,f5,f6) as test VFP9 select icase(f5>f6,f5,f6) as test SQL Server: select case when f5>f6 then f5 else f6 as test HTH _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** 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.

