Hi Jeff,
If you are executing SQL against VFP tables, (not SQL Pass Through) you can include the iif() in the field list:
SELECT iif(x = 0, 0, y/x) as pct ...
but from your question it sounds like you may want to use the SQL MAX() function instead. For example, if I want the latest date for a patient visit I would code:
SELECT PatientId, MAX(VisitDt) FROM table GROUP BY PatientId
>Does anyone know how I can implement IIF statements in an SQL. I am running a SQL select statement that looks for the patient id but the problem arises when the patient has two different visit dates to the doctor. but I only need the latest date.
>
>Jeff T.
HTH,
Bill Armbrecht
VFP MCP