如果我横向的数据用下面的语句:
Set EngineBehavior 70
Select Dw As 单位, ;
Iif(语文 < "D" And 数学 < "D" And 外语 < "D" And 物理 < "D" And 化学 < "D" And ;
生物 < "D" And 政治 < "D" And 历史 < "D" And 地理 < "D", 1, 0) As 合格数, ;
Iif(语文 = "A", 1, 0) + Iif(数学 = "A", 1, 0) + Iif(外语 = "A", 1, 0) + ;
Iif(物理 = "A", 1, 0) + Iif(化学 = "A", 1, 0) + Iif(生物 = "A", 1, 0) + ;
Iif(政治 = "A", 1, 0) + Iif(历史 = "A", 1, 0) + Iif(地理 = "A", 1, 0) As 优秀数 ;
From "0000" Order By Dw Into Cursor Query
Select 单位, Sum(合格数) As 合格数, Round(Sum(合格数)/Cnt(*)*100, 2) As 合格率, ;
Sum(Iif(优秀数 > 5, 1, 0)) As 优秀数, Round(Sum(Iif(优秀数 > 5, 1, 0))/Cnt(*)*100, 2) As 优秀率 ;
From Query Group By 单位
&& Into Cursor Query1
如果要竖向的数据用 Select Union 的语句