|
Sub 总分统计()
Dim cnn As Object, strPath As String, str_cnn As String
Dim strSQL As String, rst As Object
Sheets("八年总分").Range("A4:AO4").ClearContents
strPath = ActiveWorkbook.FullName
Set cnn = CreateObject("adodb.connection")
If Application.Version < 12 Then
str_cnn = "Provider=Microsoft.jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & strPath
Else
str_cnn = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & strPath
End If
cnn.Open str_cnn
strSQL = "Select '慈云中学',count(T.姓名),Sum(T.总分),avg(T.总分),max(T.总分),min(T.总分)," & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=630 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=620 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=610 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=600 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=590 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=580 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=570 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=560 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=550 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=540 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=530 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=520 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=510 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=500 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=490 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=480 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=470 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=460 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=450 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=440 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=430 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=420 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=410 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=400 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=390 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=380 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=370 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=360 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=350 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=340 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=330 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=320 ), " & _
"(select count(姓名) from [学生成绩$A3:M] where 总分>=310 ), (select count(姓名) from [学生成绩$A3:M] where 总分>=300 ), (select count(姓名) from [学生成绩$A3:M] where 总分<300 )" & _
"from [学生成绩$A3:M] as T"
Debug.Print strSQL
Set rst = cnn.Execute(strSQL)
Sheets("八年总分").Cells(4, 1).CopyFromRecordset rst
MsgBox ("统计完成")
End Sub
|
|