Questions tagged [outer-apply]
65 questions
-1
votes
2 answers
return 1 row from multiple case statements
In the following Query below in the port with the case statements I'm trying to figure out how to not return a null value when the SegmentType doesn't match.
QRSubscriberTag,MLKSubscriberTag, QTMSubscriber Tag, are actually a table of Tags uniquely…

GnisPL
- 3
- 5
-1
votes
1 answer
Incorrect syntax near OUTER
Very disappointing, but some how not able to crack why I am getting this error?
SELECT 1
FROM dbo.[Call] C WITH (nolock)
OUTER APPLY
(
SELECT TOP 1 LastModifiedDateTime,LastModifiedUser,Note
FROM dbo.Note
WHERE…

AK47
- 3,707
- 3
- 17
- 36
-2
votes
1 answer
Im trying to use DISTINCT and ORDER BY DESC with OUTER APPLY (2 tables), cannot get DESC order
I am using the following query and i manage to get results ordered by Id ASC (from Table2), however I want to get the result ordered by Id (table2) DESC.
Table…

Qëndrim Izairi
- 17
- 7
-2
votes
1 answer
SPROC with Outer-Apply returns too many rows
I have a complicated enough SPROC, which I modified to return a few more columns (from additional tables).
What I wanted is to have this SPROC still to return the same amount of rows and the same data, but to fill in new columns (if data exists) as…

KVN
- 863
- 1
- 17
- 35
-2
votes
2 answers
Optimize query with multiple OUTER APPLY
I'm having query with multiple OUTER APPLY but all tables have primary keys on joined columns (so clustered indexes are used here) so I don't know how to optimize this query futher. Also it's impossible to use indexed view here because using ORDER…

Vadim Ovchinnikov
- 13,327
- 5
- 62
- 90