SQL Server Calculated Column

前端 未结 1 1436
太阳男子
太阳男子 2021-01-18 10:35

I have two columns, both int\'s, Wins and Losses. I have a calculated column WinPercentage as a decimal(14,3), I want thi

相关标签:
1条回答
  • 2021-01-18 11:08
    CREATE TABLE WinLoss
    (
     TeamId int IDENTITY(1,1) NOT NULL,
     Wins int,
     Losses int,
     WinPercentage AS CASE WHEN wins > 0 THEN (Wins + Losses) / Wins ELSE 0 END
    )
    
    0 讨论(0)
提交回复
热议问题