"Edward Lau" wrote...
Hi Jose:
In SQL, aggregate function cannot be used in the WHERE clause. Use the
HAVING clause instead.
Try this:
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
Thanks.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users