This is a silly question but I need help on this.
I have a table of 50 rows. Each one has customer transaction data.
I want to create a stored procedure where if I send a customer name parameter, I want to select all the the transactions for that customer and sum the amount of transactions in groupings of 5.
So for example,
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
Customer1 05/15/2004 $10,000
So the logic is the first set of 5 have a sum > $30000 INSERT into exception
The second, although the same customer, is ok.
How do you get a grouping as such in SQL?
Thanks for the help.