Is it possible to combine these two queries into one query?
SELECT sum(amount) as credit FROM statement WHERE userId= '33003' AND debitOrCredit = '1' AND actionDate <= '2012-10-17';
SELECT sum(amount) as debit FROM statement WHERE userId= '33003' AND debitOrCredit = '0' AND actionDate <= '2012-10-17';
so I get the result:
| credit | debit |
| 90 | 60 |
You could use
CASEwithin your SUM: