u010995544
12ewsdx
采纳率0%
2019-01-24 13:25

sql查询语句通过传递参数显示多个结果

5

表是这样的
表是这样。BetText有些是多个数字。
<%

dim conn

set conn=server.createobject("ADODB.connection")

connstr="driver={SQL Server};Server=数据库连接"

Set con = Server.CreateObject("ADODB.Connection")
con.open connstr
If Err Then
err.Clear
Set con = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
end if

Set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select sum(BetMoney) as '01' from Six_Bet where BetText like '%01%' and BetLx=1 and GameID=(select max(GameID) from Six_Bet)",con,1,1

For i=1 to rs.recordcount

Response.Write "01="
Response.Write ""&rs("01")&"元
"

rs.movenext
Next
rs.close

rs.open "select sum(BetMoney) as '02' from Six_Bet where BetText like '%02%' and BetLx=1 and GameID=(select max(GameID) from Six_Bet)",con,1,1

For i=1 to rs.recordcount

Response.Write "02="
Response.Write ""&rs("02")&"元
"

rs.movenext
Next
rs.close

set rs=nothing
con.close
set con=nothing
%>

能否一条sql语句查询通过rs的值
Response.Write "02="
Response.Write ""&rs("参数值")&"元
"
显示多个结果
asp写的。不太懂

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • ndgail2008 ndgail2008 2年前

    select A,sum(BetMoney) as money from (SELECT CASE WHEN BetText LIKE '%01%' THEN '01' WHEN OrderNo LIKE '%02%' THEN '02' ELSE '' END AS A,BetMoney
    FROM Six_Bet where BetLx=1 and GameID=(select max(GameID) from Six_Bet)) t group by A

    
    
    点赞 评论 复制链接分享

相关推荐