Greetings!
I have this SELECT,
SELECT cust,
ProjID,
proj,
A_No,
bdate,
CASE Xtra4 WHEN 'y' THEN vEmail ELSE 'noemail' END,
sum(ProjFund),
sum(ProjFund)-sum(CASE Xtra4 WHEN 'y' THEN invoice ELSE 0 END),
sum(CASE Xtra4 WHEN 'y' THEN invoice ELSE 0 END)
from LSOpenJobs
WHERE
lower(cust) = 'phin' AND
PClass='Language' AND
(bdate BETWEEN '2014-01-15' AND '2014-05-15')
GROUP BY cust, ProjID, proj, A_No
HAVING
sum(case Xtra4 when 'y' then invoice else 0 end) > 0;
works great, but I am having problem with this entry,
CASE Xtra4 WHEN 'y' THEN vEmail ELSE 'noemail' END,
And the problem is that because the last record matching the SELECT has the
valune for Xtra4='n', which causes the result for the select to always
default to the ELSE 'noemail' value. What should be returned is the value
of vEmail of the first record that has Xtra4='y' and then, this rule should
not even be executed. Any help would be greatly appreciated. Thanks so
much.
josé
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users