cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function in databricks

g96g
New Contributor III

Im having a hard time to convert below function from SSMS to databricks function. Any help would be appreciated!

CREATE FUNCTION [dbo].[MaxOf5Values] (@D1 [int],@D2 [int],@D3 [int],@D4 [int],@D5 [int]) RETURNS int
AS
BEGIN
    DECLARE @Result int
 
    SET @Result = COALESCE(@D1, @D2, @D3, @D4, @D5)
 
    IF @D2 IS NOT NULL AND @D2 > @Result SET @Result = @D2
    IF @D3 IS NOT NULL AND @D3 > @Result SET @Result = @D3
    IF @D4 IS NOT NULL AND @D4 > @Result SET @Result = @D4
    IF @D5 IS NOT NULL AND @D5 > @Result SET @Result = @D5
 
    RETURN @Result
END

1 REPLY 1

Ajay-Pandey
Esteemed Contributor III

Hi @Givi Salu​ ,

Please refer to this link that will help you convert this function.

Ajay Kumar Pandey