Free for PREMIUM members
SELECT [ToCompany], AmountReceived,  as 'From aa1',  as 'From bb1',  as 'From cc1'
SELECT R1.ToCompany, R2.FromCompany, R2.Amount,d.AmountReceived
FROM tblCompany_Receipts AS R1 INNER JOIN
tblCompany_Receipts AS R2 ON R1.ID = R2.ID inner join
(SELECT ToCompany, SUM(Amount) AS AmountReceived FROM tblCompany_Receipts GROUP BY ToCompany) d on R1.ToCompany=d.ToCompany
FOR FromCompany IN( ,,)) AS pvt
-- ToCompany AmountReceived From aa1 From bb1 From cc1
-- A 50000.00 35000.00 10000.00 5000.00
Open in new window
SELECT SUM(CASE WHEN TOcompany IS NOT NULL THEN Amount ELSE 0 END) as TOcompanyTotal
, SUM(CASE WHEN FromCompany IS NOT NULL THEN Amount ELSE 0 END) as FromCompanyTotal
Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.
select 'TOcompanytotal amount: ' + cast((select sum(Amount) from tbl As x where x.ToCompany =z.ToCompany and x.FromCompany Is Null) as nvarchar(25)) +' and fromCompanyTOtalamount: '+ cast((select sum(Amount) from tbl as y WHERE y.ToCompany =z.ToCompany and y.FromCompany is not null) as nvarchar(25))
from tbl As z
group by z.ToCompany
Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!