39.SQL SERVER - CROSS APPLY | OUTER APPLY

Veröffentlicht am: 10 Mai 2024
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video 39.SQL SERVER - CROSS APPLY | OUTER APPLY mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Tech2BI 10 Mai 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 62 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!