怎样实现分类统计?!~~急
我想在表单中通过下拉框选择不同的字段(可选择具体值也可选择空)来实现分类统计即根据表单提交的条件从数据库中查找信息。
但有这么多条件我不知道怎么写sql语句(主要是and的有无)
请大家指点,谢谢!!!!
<%
dim searchday
if request("DateSearch")="all" then
searchDay=""
else
searchDay=" DATEDIFF('d',addtime2,Now()) < "&request("DateSearch")
end if
dim fhname
if request("fhname")="" then
fhname=""
else
fhname=" fhname='"&request("fhname")&"'"
end if
dim jgdw
dim he
if request("jgdw")="" then
jgdw=""
else
jgdw="jgdw='"&request("jgdw")&"'"
end if
dim tj
if request("DateSearch")="all" and request("fhname")="" and request("jgdw")="" then
tj=""
else
tj="where"
end if
dim he1,he2,he3
if searchDay<>"" and request("fhname")<>"" then
he1="and"
else
he1=""
end if
if (searchDay<>"" or request("fhname")<>"") and request("jgdw")<>"" then
he2="and"
else
he2=""
end ifdim pagecount,page,Spage,Epage,recordcount,i
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs = server.CreateObject ("Adodb.recordset")sql="select * from huowu "&tj&searchday &he1&fhname&he2&jgdw&" order by hwid desc"
rs.open sql,conn,1,1