I'm facing a piece of code that seems very difficult for me to comprehend tho I have a brief understanding how both Select TOP 0 and Outer APPLY work separetely. What does this code do? Thanks is advance!
select * from taxex t1
outer apply
(select top 0 id, b_date, total_sum from loans t2 where t1.id = t2.id
and t1.i_date >= t2.b_date) ```
1条答案
按热度按时间6rqinv9w1#
The only possibly useful action of the
outer apply
in question is the null values in columns generated by theouter apply
are casted to the type of respective columns of theloan
table. Compare:The query below will fail with
Msg 241 Level 16 State 1 Line 1 Conversion failed when converting date and/or time from character string.
While the next one is ok