DECLARE @x1 FLOAT
DECLARE @x2 FLOAT
DECLARE @y1 FLOAT
DECLARE @y2 FLOAT
SELECT @x1 = 1, @x2 = 2, @y1 = 1, @y2 = 2
SELECT (@y2-@y1)/(@x2-@x1)
-----------------------------------------------------
1.0
(1 row(s) affected)
Oder als UDF
CREATE FUNCTION dbo.steigung(@y1 FLOAT,@y2 FLOAT, @x1 FLOAT, @x2 FLOAT)
RETURNS FLOAT
AS
BEGIN
RETURN (@y2-@y1)/(@x2-@x1)
END
GO
SELECT dbo.steigung(1,2,1,2)
DROP FUNCTION dbo.steigung
-----------------------------------------------------
1.0
(1 row(s) affected)