How to do query and display the records until it reaches a certain number?
Suppose you want to select student until the total sum of the student's money reaches 1000?
Addition
Student ID Student Name Student Money
--------- ----------- --------------
1 John 190
2 Jenny 290
3 Ben 200
4 Andy 120
5 Lynna 300
If I wanna stop at 500, I would get record number 1 and 2 (190 + 290). If I wanna stop at 1000, I would get record 1 until 4.