SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


APPLY - 1


APPLY - 1

Author
Message
bitbucket-25253
bitbucket-25253
SSC-Forever
SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)

Group: General Forum Members
Points: 42041 Visits: 25280
Comments posted to this topic are about the item APPLY - 1

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Hugo Kornelis
Hugo Kornelis
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41247 Visits: 13495
Good, solid question, Ron. And on a subject that probably can use a bit more propaganda; I think many SQL Server people still don't really know what APPLY is and how it works. And it's good to see the "1" in the question name; I have a feeling that I already know what I can expect in the follow-up question.

My only (minor) gripe is the order in which the answer options are presented. Why not simply order them (lowest to highest or highest to lowest) instead of this random order?


Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)

Group: General Forum Members
Points: 180080 Visits: 13357
Thanks for this question on the basics Ron.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Raghavendra Mudugal
Raghavendra Mudugal
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6544 Visits: 2958
Thank you, Bitbucket. This question is very nice.

Initially I picked 6 and then changed to 5, thinking of the S in A has 6 unique value and then R in A has only 5 unique values and was expecting it will work like LEFT JOIN and was wrong.

Also I was expecting the data will be dirty, but seeing the dataset each row has its unique representation with the combination of A-R and B-R.


S R S
Alpha D1234 1001
Alpha D1234 2001
beta A1122 3001
beta A1122 4001
bravo C1342 5001
charlie D1234 1001
charlie D1234 2001
harry A1122 3001
harry A1122 4001



ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
Erav
Erav
Old Hand
Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)Old Hand (349 reputation)

Group: General Forum Members
Points: 349 Visits: 168
very good question. Thanks.

-Erav
Arthur Olcot
Arthur Olcot
SSCertifiable
SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)

Group: General Forum Members
Points: 5028 Visits: 1779
Great question!... i kept counting 10 records until I realised that "Doug" would actually be eliminated from the apply.

Thanks.
Christian Buettner-167247
Christian Buettner-167247
SSCrazy Eights
SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)

Group: General Forum Members
Points: 9809 Visits: 3889
Good question, but the answer from MS is not really applicable, since we have a sub-query expression and not a TVF in the QTOD example.

The more verbose explanation is documented with the FROM clause:
http://msdn.microsoft.com/en-us/library/ms177634%28v=sql.105%29.aspx

Best Regards,

Chris Büttner
Tom Thomson
Tom Thomson
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60785 Visits: 13181
Good question.

Too early in the morning for me, apparently my brain thinks that 2+2+2+1+0+2 = 8 before breakfast.

Tom

skanker
skanker
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2075 Visits: 1385
Thanks for this question - I really enjoyed trying to work it out in my head. That I then got it right was an added bonus to create a good start to the day.

Being able to copy and paste the the query into management studio is a good way to follow up on this learning - so thanks for the change in policy on QoD's. I never had time to type in some of the queries that were submitted previously so quite possibly did not get the most from them.
Rob Schripsema
Rob Schripsema
SSCertifiable
SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)

Group: General Forum Members
Points: 5619 Visits: 11042
Great question! A bit mind numbing at ...let's see...it's 1:30am here ...Doze ... but a good refresher on CROSS APPLY. Thanks!

Rob Schripsema
Propack, Inc.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search