cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.