SELECT (CASE WHEN entry_account.balance > 0 THEN entry_account.balance ELSE null END) AS debit, accounts.title
FROM ((entry_account INNER JOIN
accounts ON entry_account.account_id = accounts.id) INNER JOIN
entry ON entry_account.entry_id = entry.id)
WHERE (entry.id = ?)
Basically, the above code simply wants to put a value in the debit column if entry_account.balance is > 0 else NULL is appended. This is not exactly what my business logic is but I just have to make it simpler to actually get myself familiarized with the CASE syntax.
The problem is, it just doesn't work. I browsed a couple of code snippets and all of them don't give my an idea why my code is wrong.
Have to sleep now, I might just get the answer tomorrow.
Subscribe to:
Post Comments (Atom)

2 comments:
What exactly is the error that you are getting?
Post a Comment