On 5/30/2014 1:29 PM, jose isaias cabrera wrote:
Good point. I was, wrongly, thinking that it was top to bottom with the
id. So, the idea is that once Xtra4='y' has provided a value, that is
what I want. So, I think that because I am always getting 'noemail'
then, it is caused because the last record read had Xtra4!='y'. So,
this is not properly giving the result desired. So, how can I change this,
CASE Xtra4 WHEN 'y' THEN vEmail ELSE 'noemail' END,
so that once I have a value from Xtra4='y', I want to keep that value as
the result. Thanks.
SELECT ...
ifnull(
(select t2.vEmail from LSOpenJobs t2
where t2.ProjID = min(CASE t1.Xtra4 WHEN 'y' THEN t1.ProjID ELSE null
END)),
'noemail'),
...
from LSOpenJobs t1 ...;
This gives you, for each group, vEmail value corresponding to the row
with the smallest ProjID among those where Xtra4='y'; if there's no such
row, it produces 'noemail'.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users