如下面的代码,可以显示 select 语句为
Select 姓名,部门,基本绩效,sum(当月人天) As [当月人天] Fro m {XMFP} Inner JOIN {人员信息表} ON {人员信息表}.[姓名] = {XMFP}.[成员] Group By 姓名,部门,基本绩效
Dim jb As New SQLJoinTableBuilder("统计表1","XMFP")
Dim sl As String
jb.C
jb.AddTable("XMFP","成员","人员信息表","姓名")
jb.AddCols("姓名", "部门","基本绩效",True)
jb.AddExp("当月人天","sum(当月人天)")
jb.Build()
MainTable = Tables("统计表1")
sl = jb.BuildSQL()
Output.Show(sl)
但是能不能够通过SELECT语句生成窗口命令的代码呢。
例如这个语句
selec t 姓名,基本绩效, 部门 ,sum(奖金) as 总奖金 fro m (
selec t a.姓名,a.部门,a.基本绩效, case when 等级='YI级' then 一级奖金*当月人天 when 等级='ER级' then 二级奖金*当月人天 else 0 end as 奖金 fro m {人员信息表} a inner join
(selec t 一级 as 姓名, 'YI级' as 等级, 部门,基本绩效,当月人天 fro m {XMFP} Inner JOIN {人员信息表} ON {人员信息表}.[姓名] = {XMFP}.[成员] Where 任务开始 >= '01-01-2018' and 任务开始 < '02-01-2018 ' union
sele ct 二级 as 姓名, 'ER级' as 等级,部门,基本绩效, 当月人天 fro m {XMFP} Inner JOIN {人员信息表} ON {人员信息表}.[姓名] = {XMFP}.[成员] Where 任务开始 >= '01-01-2018' and 任务开始 < '02-01-2018 ') b on a.姓名=b.姓名) as c group by 姓名,部门,基本绩效