We have one table where there is a column player_id and another transaction_type (deposit || withdrawal)
We have one table where there is a column player_id and another transaction_type (deposit || withdrawal)
how to make a request to take the amount of the amount_local column and group it so that it is clear how many deposits there were and how many were withdrawn from one person and group it by player_id
2
Answers
The transaction_type column can be used to distinguish between deposits and withdrawals, and the GROUP BY clause can be used to group the results by player_id. Here is an illustration SQL command for both tables:
You will receive a return set from the above query that includes the columns player_id, transaction_type, and total_amount. Transaction_type will either be "deposit" or "withdrawal," and total_amount will be the total of the amounts for each player_id and transaction_type combination.
Hope it works 🙂
It’s really simple. You can use SQL’s SUM() function together with a CASE statement to discriminate between deposit and withdrawal transactions in order to retrieve the total deposit and withdrawal amounts aggregated by player_id. Here is a sample inquiry:
Your_table_name
should be changed to the name of your table. The total deposit and withdrawal amounts for each player are determined by adding the values in theamount_local
column for eachplayer_id
separately.Hope this helps, do let me know if you need more help.