jose isaias cabrera <[EMAIL PROTECTED]>
wrote:
> Greetings...
>
> I know that Puneet will get on my case about the obscurity of the
> subject (just kidding), but I am trying to find out if I can do this:
> Imagine this table and data...
>
> Class|ProjID|ProjFund|Invoice|Split
> Finishers|1045|73||
> Finishers|1045|75|30|
> Finishers|1045|75|30|
> Finishers|1045|75|30|
> Finishers|1045|75||
> Finishers|1045|75|75|y
> Finishers|1045|75|25|
> Finishers|1045|73||
> Finishers|1045|73||
> Finishers|1045|73||
> Finishers|1045|73|58.4|y
> Finishers|1045|73||
>
> What I would like is to have total of ProjFund, a total of ProjFund -
> Invoices which Split = 'y' and a total of Invoices which Split = 'y'.
>
> I know I can do this programatically, but I would like to be able to
> have sqlite return the results to me. Is it possible? What I have
> right now is this,
>
> SELECT Class, sum(ProjFund), sum(ProjFund) - sum(invoice),
> sum(invoices) from ClassTable group by Class, ProjID;
>
> I just don-t know how to do the Split = 'y' part. Any help would be
> greatly appreciated.
Perhaps something like this:
SELECT Class,
sum(ProjFund),
sum(ProjFund) - sum(case split when 'y' then invoice else 0 end),
sum(case split when 'y' then invoice else 0 end)
from ClassTable group by Class, ProjID;
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users