I was wondering if I could get any help with the following problem.
I have a table of transactions (simplified below) and I only want to select transactions until my
Although it may not be the most efficent way (as you're still, in essence, selecting everything first), I'd look at using a running total.
Something like:
SELECT
*
FROM
(
SELECT
id
, date
, amount
, (SELECT SUM(amount) FROM Transactions WHERE id <= t.id) AS RunningTotal
FROM
Transactions t
) t1
WHERE
t1.RunningTotal < 6