Below I have two tables #temp and # temp2.
create table #temp ( col1 int ) insert into #temp values(6),(1),(2),(3),(null) create table #temp2 ( col1 int ) insert into #temp2 values(1),(2),(1),(2),(3),(null)
And also I have two queries below With INNER JOIN:
SELECT t1.col1, Sum(t2.col1) AS col1 FROM
Result:
col1 col1 1 2 2 4 3 3
And the second request
Using CROSS APPLY:
SELECT * FROM
Result:
col1 col1 1 2 2 4 3 3 6 NULL
Now I want to know the difference between CROSS APPLY and INNER JOIN. I know CROSS APPLY is similar to INNER JOIN. For each and every #temp entry (first table), cross is applied. Execute But I get a different result set based on the above result sets. Can anyone clarify?
Thanks in advance.
Aj.na source share