I have database with 4-5 tables. I'm collecting data like this
N | Nom_ | Soni_ | Savdo | Foyda | Val(Currency) 1 | Apple | 5kg | 5000 | 500 | UZS 2 | Banana| 4kg | 7000 | 800 | UZS 3 | Peach | 2kg | 2 | 0.2 | USD
And I want to separate Currency column two column like below
N | Nom_ | Soni_ | Savdo | Foyda | Val1 | Val2 1 | Apple | 5kg | 5000 | 500 | UZS | 2 | Banana| 4kg | 7000 | 800 | UZS | 3 | Peach | 2kg | 2 | 0.2 | | USD
Here is my SQL code.
select s.nom_ , sum(o.soni_) as soni_ ,
sum(o.soni_*(select narx_ from toper where id_=o.id_ )) as savdo_,
sum((o.soni_*o.narx_-o.soni_* (select narx_ from toper where id_=o.id_op ))) as foyda_,
(select nom_ from tsinf where id_=o.id_v) as val_
from toper o left join tsf f on o.id_sf=f.id_
left join tsinf s on o.id_s=s.id_
where (f.date_>=date('2020-01-01')) and (f.date_<=date('2020-04-04'))
and f.oper_=-1 group by id_s, id_v