I need to select records until the total of a column reaches a variable number.

I have a query that sort of works but not 100%. I also want to see the call\_date and I want the count to be done in order of date. 

```
SELECT NULL AS inbound_duration, NULL AS total
  FROM dual
 WHERE (@total := 0)
 UNION
SELECT inbound_duration,  @total := @total + inbound_duration AS total
FROM `records` where calling_user = '1' and call_date LIKE '2016-05-%%' and @total < 5000 ORDER BY call_date

```

<http://sqlfiddle.com/#!9/2e74ff>