|
-
I don't see why rows with ID = 5,6,7 exist. Particpant 6000 had zero balance for those draws, so why was he included in them? If you exclude them, then you get the answer = 4.
I probably didn't correctly distinguish between draws & tickets (I'm not sure now what a ticket is), should it be:
sum(payments) - count(draws)*price
? ? ?
If the data really will look like that, then the definition of the balance is procedural, as function of the time sequence. In which case SQL won't answer - you'll need PL/SQL or C or something. To avoid the overhead of reading everything every time, you would probably want to de-normalise your model and store the "balance at time of draw" in another table.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|