select date
, sum( case when ppcc.dt = 1 then ppcc.sum else 0 end )
, sum( case when ppcc.dt = 0 then ppcc.sum else 0 end )
from (
select
pp.date as date
, 1 as dt
, pp.sum as sum
from payments pp
union all
select
pp.date as date
, 0 as dt
, pp.sum as sum
from cash cc
) ppcc
group by ppcc.date