sql set variable using COUNT

后端 未结 4 1843
陌清茗
陌清茗 2021-02-04 23:50

I am trying to make a simple query to my server and want the result to be stored in the variable @times.

DECLARE @times int

SET @times = SELECT COUNT(DidWin)as          


        
4条回答
  •  没有蜡笔的小新
    2021-02-05 00:20

    You can use SELECT as lambacck said or add parentheses:

    SET @times = (SELECT COUNT(DidWin)as "I Win"
    FROM thetable
    WHERE DidWin = 1 AND Playername='Me');
    

提交回复
热议问题