Discussion Board

Welcome to Contrib.com Discussion Board, where you can post topics and receive comments from other members of the community.

All Categories

How to use user variable as counter with inner join queries that contains GROUP BY statement?

+1
Votes
1
Comments
I have 2 tables odds and matches : matches : has match_id and match_date odds : has id, timestamp, result, odd_value, user_id, match_id I had a query that get the following information from those tables for each user: winnings : the winning bets for each user. (when odds.result = 1) loses : the lost bets for each user.(when odds.result != 1) points : the points of each user.(the sum of the odds.odd_value) for each user. bonus : for each continuous 5 winnings i want to add extra bonus to this variable. (for each user) How to calculate bonus? I tried to use this query and I faced a problem : (you can check it here SQL Fiddle) the calculated bonus are not right for all the users : first user:(winnings:13, bonus=2). second user:(winnings:8, bonus=2)bonus here should be 1. third user:(winnings:14, bonus=3)bonus here should be 2. why does the query not calculate the bonus correctly?
posted in Technology by Maida Barrientos Mar 04,2015 03:48 am

Comment/s:

+0
Votes
give me your query
commented by Bloch Jaid Apr 29,2015 04:05 am