我的数据按ID和checkdate进行分组,这样每个人在每次checkDate时都会收到一行检查。我有每个checkDate的总金额(YTDGross)和延期金额(YTD401K)的列。
我想计算3个额外的列。
第一个使用以下公式计算匹配数量(匹配):
const string mapper_reducer_Path = "FULL S3 Path ";
const string mapperFileName = "YourMapper.rb";
const string reducerFileName = "YourReducer.rb";
string mapperFilePath = string.Format("{0}/{1}", mapper_reducer_Path, mapperFileName);
string reducerFilePath = string.Format("{0}/{1}", mapper_reducer_Path, reducerFileName);
StreamingStep stepConfig = new StreamingStep
{
Inputs = new List<string>
{
"YOURInput",
},
Output = "YOUrOUTPUT",
Mapper = mapperFileName,
Reducer = reducerFileName,
};
HadoopJarStepConfig config = stepConfig.ToHadoopJarStepConfig();
config.Args.Insert(0, "-files");
config.Args.Insert(1, string.Format("{0},{1}", mapperFilePath, reducerFilePath));
公式本身是无关紧要的,除了它引用另一个也需要计算的列:PriorYTD401kMatch。而这一列依次是从第三列开始计算的 - 它是前一行的YTD401KMatch。
YTD401KMatch只是PriorYTD401kMatch + Match
我无法在SQL Server 2012中看到这是如何实现的,因为三个新列中的每一个都以迂回的方式相互依赖。有人随时向我展示光明。
这是我被困之前的最新选择:
IIF(YTD401K<=.04*YTDGross,IIF(YTDGross<=265000,YTD401K-PriorYTD401kMatch,
IIF((YTD401K-PriorYTD401kMatch)>(10600-PriorYTD401kMatch),10600-PriorYTD401kMatch,YTD401K-PriorYTD401kMatch)),
IIF(YTDGross<=265000,(ROUND(.04*YTDGross,2)-PriorYTD401kMatch),10600-PriorYTD401kMatch)) AS Match