可以代码:
Dim s1 As Integer = val(Left("2017年秋季",4))
Dim SQL As String = "IIF(b.学期 Like '%秋%',IIF(('"& s1 &"' - val(Left(b.学期,4))) *100 + val(班级) < 1000,('"& s1 &"'- val(Left(b.学期,4))) *100 + val(班级)),IIF(b.学期 Like '%春%',IIF(('"& s1 &"' - val(Left(b.学期,4))) *100 + val(班级) < 1000,('"& s1 &"'- val(Left(b.学期,4))) *100 + val(班级))))"
Dim SQL1 As String = "IIF(Left(" & SQL & ",1) = 1,'一年级',IIF(Left(" & SQL & ",1) = 2,'二年级',IIF(Left(" & SQL & ",1) = 3,'三年级',IIF(Left(" & SQL & ",1) = 4,'四年级',IIF(Left(" & SQL & ",1) = 5,'五年级',IIF(Left(" & SQL & ",1) = 6,'六年级',IIF(Left(" & SQL & ",1) = 8,'八年级',IIF(9 = 9,'九年级'))))))))"
Dim SQL2 As String = "Select b.学期,b.学生编号,学生姓名,"& SQL1 &" As 年级 Fr om (({学生基本信息} a Inner JOIN {缴退费信息} b ON a.学生编号 = b.学生编号) Inner JOIN {违规信息} c ON b.学生编号 = c.学生编号) Inner JOIN (Select 学生编号,max(缴费日期) As 缴费日期 Fr om {缴退费信息} WHERE 缴费项目 = '学费' And 缴费状态 = '已缴' GROUP BY 学生编号) n on b.学生编号 = n.学生编号 And b.缴费日期 = n.缴费日期 WHERE 缴费项目 = '学费' And 缴费状态 = '已缴' And c.审批状态 = '拒绝报名'"
不可以代码:
Dim s1 As Integer = val(Left("2017年秋季",4))
Dim SQL As String = "IIF(b.学期 Like '%秋%',IIF(('"& s1 &"' - val(Left(b.学期,4))) *100 + val(班级) < 1000,('"& s1 &"'- val(Left(b.学期,4))) *100 + val(班级)),IIF(b.学期 Like '%春%',IIF(('"& s1 &"' - val(Left(b.学期,4))) *100 + val(班级) < 1000,('"& s1 &"'- val(Left(b.学期,4))) *100 + val(班级))))"
Dim SQL1 As String = "IIF(Left(" & SQL & ",1) = 1,'一年级',IIF(Left(" & SQL & ",1) = 2,'二年级',IIF(Left(" & SQL & ",1) = 3,'三年级',IIF(Left(" & SQL & ",1) = 4,'四年级',IIF(Left(" & SQL & ",1) = 5,'五年级',IIF(Left(" & SQL & ",1) = 6,'六年级',IIF(Left(" & SQL & ",1) = 7,'七年级',IIF(Left(" & SQL & ",1) = 8,'八年级',IIF(9 = 9,'九年级'))))))))"
Dim SQL2 As String = "Select b.学期,b.学生编号,学生姓名,"& SQL1 &" As 年级 Fr om (({学生基本信息} a Inner JOIN {缴退费信息} b ON a.学生编号 = b.学生编号) Inner JOIN {违规信息} c ON b.学生编号 = c.学生编号) Inner JOIN (Select 学生编号,max(缴费日期) As 缴费日期 Fr om {缴退费信息} WHERE 缴费项目 = '学费' And 缴费状态 = '已缴' GROUP BY 学生编号) n on b.学生编号 = n.学生编号 And b.缴费日期 = n.缴费日期 WHERE 缴费项目 = '学费' And 缴费状态 = '已缴' And c.审批状态 = '拒绝报名'"
区别:可以
Dim SQL1 As String = "IIF(Left(" & SQL & ",1) = 1,'一年级',IIF(Left(" & SQL & ",1) = 2,'二年级',IIF(Left(" & SQL & ",1) = 3,'三年级',IIF(Left(" & SQL & ",1) = 4,'四年级',IIF(Left(" & SQL & ",1) = 5,'五年级',IIF(Left(" & SQL & ",1) = 6,'六年级',IIF(Left(" & SQL & ",1) = 8,'八年级',IIF(Left(" & SQL & ",1) = 9,'九年级'))))))))"
不可以
Dim SQL1 As String = "IIF(Left(" & SQL & ",1) = 1,'一年级',IIF(Left(" & SQL & ",1) = 2,'二年级',IIF(Left(" & SQL & ",1) = 3,'三年级',IIF(Left(" & SQL & ",1) = 4,'四年级',IIF(Left(" & SQL & ",1) = 5,'五年级',IIF(Left(" & SQL & ",1) = 6,'六年级',IIF(Left(" & SQL & ",1) = 7,'七年级',IIF(Left(" & SQL & ",1) = 8,'八年级',IIF(Left(" & SQL & ",1) = 9,'九年级'))))))))"
[此贴子已经被作者于2018/5/10 21:47:13编辑过]