Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

APPLY - 1 Expand / Collapse
Author
Message
Posted Wednesday, September 05, 2012 8:12 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:02 AM
Points: 5,469, Visits: 23,457
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
Post #1354989
Posted Thursday, September 06, 2012 12:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 1:54 PM
Points: 5,787, Visits: 8,001
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 MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1355045
Posted Thursday, September 06, 2012 12:35 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:46 AM
Points: 12,176, Visits: 9,128
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?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1355050
Posted Thursday, September 06, 2012 12:47 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 8:09 AM
Points: 669, Visits: 1,538
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
--
There are only 10 types of people in the world, those who understand binary, and those who don't.

Note: (as of now) only.. 1 and 4 applies (i am on my way...)
Post #1355056
Posted Thursday, September 06, 2012 1:05 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 8:40 AM
Points: 189, Visits: 120
very good question. Thanks.

-Erav
Post #1355069
Posted Thursday, September 06, 2012 1:09 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:35 AM
Points: 2,417, Visits: 1,564
Great question!... i kept counting 10 records until I realised that "Doug" would actually be eliminated from the apply.

Thanks.
Post #1355070
Posted Thursday, September 06, 2012 1:45 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 7:19 AM
Points: 2,814, Visits: 3,851
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
Post #1355083
Posted Thursday, September 06, 2012 1:49 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 4:56 PM
Points: 8,271, Visits: 8,717
Good question.

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


Tom
Post #1355087
Posted Thursday, September 06, 2012 2:06 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 1:54 AM
Points: 830, Visits: 1,144
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.
Post #1355096
Posted Thursday, September 06, 2012 2:55 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:08 PM
Points: 1,906, Visits: 10,941
Great question! A bit mind numbing at ...let's see...it's 1:30am here ... ... but a good refresher on CROSS APPLY. Thanks!


Rob Schripsema
Accelitec, Inc
Post #1355133
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse