39.SQL SERVER - CROSS APPLY | OUTER APPLY

Publicado em: 10 Maio 2024
no canal de: Tech2BI
62
0

In this session we will discuss about APPLY operators in sql:

https://drive.google.com/drive/u/2/fo...

-- APPLY OPERATOR (CROSS APPLY AND OUTER APPLY)

-- Apply we used to join between two table expressions.
-- Main diff between join and apply operators is when we have table vaued functions we can use on right side and evaluate each and every row of left side table.
-- when do we use join vs apply.

-- WHEN TO USE

--Use a CROSS APPLY when no easy join exists and when the right table is an expression or table-valued function.
--It's like an INNER JOIN since rows must exist in both tables/expressions for SQL to return results.

--Use OUTER APPLY when no easy join exists and when the right table is an expression or table-valued function.
--It's like a LEFT JOIN since rows do not need to exist on the right side to return results from the left table.

-- WHEN NOT TO USE

-- If you can get the same results with an inner join, don't use a CROSS APPLY.
-- It is not clear and leaves people scratching their heads.

-- If you can get the same results with a LEFT OUTER JOIN,
-- don't use an OUTER APPLY for the reason mentioned above.



-- SYNTAX

-- SELECT
--COL1,CLO2
--FROM TAB1
--CROSS/outer APPLY TAB2/TABLE_VALUEDFUNCTIONS (COL1,CLO2) AS ALIASNAME

Note: If i use any external content the actual credit goes to respective owners only.

#sql #sqlserver #database #dataanalytics #dbms #sql #tech2bi #crossappply #outerapply


Nesta página do site você pode assistir ao vídeo on-line 39.SQL SERVER - CROSS APPLY | OUTER APPLY duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Tech2BI 10 Maio 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 62 vezes e gostou 0 espectadores. Boa visualização!