У меня есть этот запрос
SELECT distinct
date(b.updated_at) as date,
sum(case when c.cash_details = "CASH IN" and is_approved = 1 then cash_user end) AS totalcashin,
sum(case when c.cash_details = "CASH OUT" and is_approved = 1 then cash_user end) AS totalcashout,
sum(ticket_num * 1000) AS 'betting amount',
sum(case when bet_details = "WIN" then winning_num end) AS 'winning amount'
FROM cash_details as c, bet_details as b
-- where date(b.updated_at) = '2019-08-22'
group by date(b.created_at)
order by date(b.created_at) desc
;
, и результат равен queryfirstpic
, но для этого запроса
select
date(created_at),
sum(ticket_num * 1000) AS 'betting amount' ,
sum(case when bet_details = "WIN" then winning_num end) AS 'winning amount'
from bet_details
-- where date(updated_at) = '2019-08-22'
group by date(created_at)
order by date(created_at) desc
;
результат равен queryoutput2nd
, а другой запрос -
SELECT date(created_at),
sum(case when c.cash_details = "CASH IN" and is_approved = 1 then cash_user end) AS totalcashin,
sum(case when c.cash_details = "CASH OUT" and is_approved = 1 then cash_user end) AS totalcashout
from cash_details as c
group by date(c.created_at)
order by date(c.created_at) desc
;
: 3-й запрос
Когда я пытался выполнить запрос к таблицам вотображать каждую сумму, запрос с 2 таблицами показывает различные значения суммы.