add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE Islem (
Category_NM int,
Category_Type VARCHAR(100),
Payment float
);

INSERT INTO Islem VALUES (1,'GİDER',1.2),(1,'GİDER',2.2),(1,'GİDER',3.2),
(2,'GİDER',1.2),(2,'GİDER',2.2),(2,'GİDER',3.2)
6 rows affected
select
Category_NM
,SUM(Payment) odemeler
,CONVERT(decimal(5,1), (
(select sum(Payment) from Islem i2 where Category_Type = 'Gider' AND i2.Category_NM = i1.Category_NM)
/ (select sum(Payment) from Islem where Category_Type = 'Gider')
) *100)
from Islem i1 where Category_Type = 'GİDER'
GROUP BY Category_NM

Category_NM odemeler (No column name)
1 6.6 50.0
2 6.6 50.0
select
i1.Category_NM
,SUM(Payment) odemeler
,CONVERT(decimal(5,1), (
SUM(i2.sum_pay)
/ (select sum(Payment) from Islem where Category_Type = 'Gider')
) *100)
from Islem i1
JOIN (select Category_NM , sum(Payment) sum_pay from Islem where Category_Type = 'Gider' group by Category_NM) i2 ON i1.Category_NM = i2.Category_NM
where i1.Category_Type = 'GİDER'
GROUP BY i1.Category_NM
Category_NM odemeler (No column name)
1 6.6 150.0
2 6.6 150.0