Hi,
I have a query that makes a left join to one table, problem is that when I
add a "When" for that table the results displayed are only for records in
which the left join exists and all other records are left out. How can I
change it so that it displays all the other records and those in which the
left join is true and the condition is true ?
This is the code without the condition (Displays all records, those when
there is a left join and those with no conection to that table).
Select distinct a.id,a.caseid,b.FirstNm,b.LastNm from cases a
inner join users as b
on a.alienid = b.userid
Inner join Processcatalog as e on a.process = e.ProcesscatalogID
left join Users as f on a.empid = f.userid
left join Activities as g on a.id = g.caseid
WHERE a.firmid = 1 AND g.acttype = 'history'
This is the code with the condition (Once the condition for the left join is
added results returned are only for records where there the left join
exists, all others are left out

.. )
Select distinct a.id,a.caseid,b.FirstNm,b.LastNm from cases a
inner join users as b
on a.alienid = b.userid
Inner join Processcatalog as e on a.process = e.ProcesscatalogID
left join Users as f on a.empid = f.userid
left join Activities as g on a.id = g.caseid
WHERE a.firmid = 1 AND g.acttype = 'history'
and (g.Lastmodified IS NOT NULL AND g.Dateinitiated IS NULL)
I hope I explained correctly..... Please HELP !!!
Z