39.SQL SERVER - CROSS APPLY | OUTER APPLY

Опубликовано: 10 Май 2024
на канале: 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


На этой странице сайта вы можете посмотреть видео онлайн 39.SQL SERVER - CROSS APPLY | OUTER APPLY длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Tech2BI 10 Май 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 62 раз и оно понравилось 0 зрителям. Приятного просмотра!