Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
COMPUTED COLUMN
CREATE TABLE Prices ( PriceId int IDENTITY(1,1) PRIMARY KEY, ActualPrice NUMERIC(16,9), PredictedPrice NUMERIC(16,9) ) go create function udf_price_index ( @ActualPrice numeric(16,9), @PredictedPrice numeric(16,9) ) returns NUMERIC(16,9) with schemabinding as begin declare @PriceIndex NUMERIC(16,9) select @PriceIndex=case(@ActualPrice) when 0 then 0 else (@ActualPrice/@PredictedPrice) end return @PriceIndex end go ALTER Table Prices add PriceIndex as dbo.udf_price_index(ActualPrice,PredictedPrice) PERSISTED -- PERSISTED (IT IS STORED VALUE PHYSICALLY IN DATABASE) INSERT INTO Prices (ActualPrice,PredictedPrice) values (10,5),(20,3),(100,200),(10,7) Select * from Prices
run
|
edit
|
history
|
help
0
SQL_Joins_RankingFunctions
Select empID whose salary is greater than their managers
db2
libros
Ejercicios de SQL (I)9
Stored procedure
Exa
Quiz
ERROR
Max from multiple columns