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 5, 2012 8:12 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, November 6, 2014 1:00 PM
Points: 5,333, Visits: 25,277
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 6, 2012 12:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:21 AM
Points: 6,098, Visits: 8,367
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 6, 2012 12:35 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:44 AM
Points: 13,562, Visits: 11,372
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 6, 2012 12:47 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:37 AM
Points: 1,037, Visits: 2,341
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.
Post #1355056
Posted Thursday, September 6, 2012 1:05 AM
SSC-Enthusiastic

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

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 9:49 AM
Points: 191, Visits: 128
very good question. Thanks.

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

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 4:44 AM
Points: 2,680, Visits: 1,678
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 6, 2012 1:45 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:56 AM
Points: 2,842, Visits: 3,876
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 6, 2012 1:49 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:45 AM
Points: 7,860, Visits: 9,606
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 6, 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: Today @ 9:17 AM
Points: 915, Visits: 1,307
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 6, 2012 2:55 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 12:51 PM
Points: 2,010, Visits: 10,969
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