* 假设你表单上有check1,check2
* 根据选择,分类统计
thisform.check1.caption = "院系"
thisform.check2.caption = "班级"
local cGroup,cSelect,cSql
cGroup = ""
cSelect = ""
if thisform.check1.value = 1
cGroup = "院系"
cSelect = "院系"
endif
if thisform.check2.value = 1
if !empty(cGroup)
cGroup = cGroup + "," + "班级"
cSelect = cSelect + "," + "班级"
endif
endif
if !empty(cGroup)
cGroup = " Group by " + cGroup
endif
if !empty(cSelect)
cSelect = cSelect + ","
endif
TEXT TO cSql TEXTMERGE NOSHOW PRETEXT 4
select <<cSelect>> max(数学) as 数学最高,max(语文) as 语文最高,max(英语) as 英语最高, ;
min(数学) as 数学最低,min(语文) as 语文最低,min(英语) as 英语最低 from 成绩表 ;
<<cGroup>>
endtext
messagebox(cSql)
&&观察生成的SQL语句
EXECSCRIPT(cSql)
&&运行SQL语句