clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2591627 fiddles created (45702 in the last week).

select @@version;
(No column name)
Microsoft SQL Server 2014 (SP3-CU-GDR) (KB4535288) - 12.0.6372.1 (X64) Dec 12 2019 15:14:11 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows NT 6.3 <X64> (Build 17763: ) (Hypervisor)
 hidden batch(es)


DECLARE @TblSatis TABLE (BelgeNo VARCHAR(10), MalzemeNo VARCHAR(30), Tutar NUMERIC(18, 2)); INSERT INTO @TblSatis VALUES ('0000000001', 'M001', 20), ('0000000001', 'M002', 30), ('0000000001', 'M002', 30), ('0000000001', 'M003', 40), ('0000000002', 'M003', 40), ('0000000002', 'M004', 60), ('0000000003', 'M005', 50); WITH ct AS (SELECT BelgeNo, MalzemeNo, SUM(Tutar) AS Toplam FROM @TblSatis GROUP BY BelgeNo, MalzemeNo) SELECT BelgeNo, MalzemeNo, Toplam, Toplam / (SUM(Toplam) OVER (PARTITION BY BelgeNo)) * 100 AS ToplamOran FROM ct;
BelgeNo MalzemeNo Toplam ToplamOran
0000000001 M001 20.00 16.666600
0000000001 M002 60.00 50.000000
0000000001 M003 40.00 33.333300
0000000002 M003 40.00 40.000000
0000000002 M004 60.00 60.000000
0000000003 M005 50.00 100.000000
 hidden batch(es)