I have two columns, both int's, Wins
and Losses
. I have a calculated column WinPercentage
as a decimal(14,3)
, I want this to be:
WinPercentage = (Wins + Losses) / Wins
What's the syntax for that?
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
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.