I will start with the table:
Query:
SELECT taw.user_id AS taw_user_id, COALESCE(SUM(tai.bid), 0) AS tai_bid, taw.win AS taw_win
FROM tb_auction_winners taw JOIN
tb_aukciono_istorija tai
ON taw.id = tai.aukciono_id
WHERE tai.user_id = 206 AND taw.user_id = 206
GROUP BY aukciono_id, taw.user_id;
My problem is that I cannot get my desired result (changed using inspect element):
It should sum all tai_bid
and taw_win
values where taw_user_id
is same. I have read SQL query to sum the data and How to take sum of column with same id in SQL? threads but it did not help. Using GROUP BY aukciono_id, taw_user_id
everything should be fine but it does not work. I guess it is a very easy fix but I cannot find what is wrong :( Help me, please.
SQL FIDDLE: http://sqlfiddle.com/#!9/6945a/1