SQL Partition data within and outside of a Common Table Expression
问题 I am using SQL Server 2012 I have the following sample result set. The columns with the Tot Prefix are derived from the columns to the left. What I am trying to do is partition data for a given date, and a given AssetStyle. Based on this criteria I want to sum profit and sum ACB. I then want to divide the results of these two sums for a total return number. The sample data is below. ValuationDate CustodianaccountNum AssetStyle AssetClass Profit ACB NetReturn TotProfit TotACB TotReturn 3/31