学校总人数: select count(*) from B
学校男生总数: select count(*) from B where sex=0
学校女生总数: select count(*) from B where sex=1
各院系总人数: select y,count(*) from B group by y
各院系男生总数: select y,count(*) from B where sex=0 group by y
各院系男生总数: select y,count(*) from B where sex=1 group by y
<body>
<table class="tableBorder" cellSpacing="1" cellPadding="3" align="center" border="0" id="table12">
<tr>
<th height="25" colspan="4" class="tableHeaderText">咸宁学院学生信息查询系统===各院系学生情况一览</th>
</tr>
<tr>
<td align="center" width=25% class="forumRow">院系名称</td>
<td align="center" width=25% class="forumRow">院系总人数</td>
<td align="center" width=25% class="forumRow">院系男生总数</td>
<td align="center" width=25% class="forumRow">院系女生总数</td>
</tr>
</table>
<%
dim rs,strSql,aRs,astrSql,bRs,bstrSql,cRs,cstrSql
Set Rs=Server.CreateObject("ADODB.Recordset")
strSql="Select * From yuan"
Rs.Open strSql,db,1,1
dim Y
Do While Not rs.Eof
Y=rs("yuan")
'******************************************************原系总人数
Set aRs=Server.CreateObject("ADODB.Recordset")
astrSql="Select * From student where 院系 Like '%" & Y & "%'"
aRs.Open astrSql,db,1,1
'******************************************************原系女生人数
Set bRs=Server.CreateObject("ADODB.Recordset")
bstrSql="Select * From student where 院系 Like '%" & Y & "%' and 性别='女'"
bRs.Open bstrSql,db,1,1
'******************************************************原系男生人数
Set cRs=Server.CreateObject("ADODB.Recordset")
cstrSql="Select * From student where 院系 Like '%" & Y & "%' and 性别='男'"
cRs.Open cstrSql,db,1,1
<%
dim rs,strSql,aRs,astrSql
Set Rs=Server.CreateObject("ADODB.Recordset")
strSql="Select * From yuan"
Rs.Open strSql,db,1,1
dim Y
Do While Not rs.Eof
Y=rs("yuan")
Set aRs=Server.CreateObject("ADODB.Recordset")
astrSql="Select * From student where 院系 Like '%" & Y & "%'"
aRs.Open astrSql,db,1,1
Response.Write ""&rs("yuan")&"" & ars.RecordCount & "人<br>"
rs.MoveNext
Loop
学校总人数: select count(*) from B
学校男生总数: select count(*) from B where sex=0
学校女生总数: select count(*) from B where sex=1
各院系总人数: select y,count(*) from B group by y
各院系男生总数: select y,count(*) from B where sex=0 group by y
各院系男生总数: select y,count(*) from B where sex=1 group by y
B里有个院系!
select * form B where y="院系"
这样么?可是那个 where="????"中
????不要自己写,这些????可以从数据库里调要么?
比方说有个 中文 合 英语!
select * form B where y="YYY"
这里的YYY怎么样才可以现表示"中文"查询完毕 再附值为"英语"