sql set variable using COUNT

后端 未结 4 1779
陌清茗
陌清茗 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:17

    You want:

    DECLARE @times int
    
    SELECT @times =  COUNT(DidWin)
    FROM thetable
    WHERE DidWin = 1 AND Playername='Me'
    

    You also don't need the 'as' clause.

提交回复
热议问题