September 5, 2012 at 8:12 pm
Comments posted to this topic are about the item APPLY - 1
September 6, 2012 at 12:30 am
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?
September 6, 2012 at 12:35 am
Thanks for this question on the basics Ron.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
September 6, 2012 at 12:47 am
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.
SRS
AlphaD12341001
AlphaD12342001
betaA11223001
betaA11224001
bravoC13425001
charlieD12341001
charlieD12342001
harryA11223001
harryA11224001
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 6, 2012 at 1:05 am
very good question. Thanks.
-Erav
September 6, 2012 at 1:09 am
Great question!... i kept counting 10 records until I realised that "Doug" would actually be eliminated from the apply.
Thanks.
September 6, 2012 at 1:45 am
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
September 6, 2012 at 1:49 am
Good question.
Too early in the morning for me, apparently my brain thinks that 2+2+2+1+0+2 = 8 before breakfast.
Tom
September 6, 2012 at 2:06 am
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.
September 6, 2012 at 2:55 am
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.
September 6, 2012 at 4:15 am
Thanks for the great question. I did good for 6:00 AM but have to research the CROSS APPLY more deeply.
September 6, 2012 at 4:43 am
This was removed by the editor as SPAM
September 6, 2012 at 5:03 am
Good question, I had it in my head that CROSS APPLY acted like an INNER JOIN and OUTER APPLY acted like an OUTER JOIN, but in fact the CROSS apply would return unique combinations, excluding NULLs on the right - hence my answer of 5.
Never mind, another QOTW chance tomorrow...
---
Note to developers:Want to get the best help? Click here https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
September 6, 2012 at 5:15 am
derek.colley (9/6/2012)
Derek, Tried the CAST statement in you Post Signature and got an error. Is it supposed to be valid SQL? Thanks.
September 6, 2012 at 6:01 am
This is the first QotD in a long time (ever?) that, after getting it right, I audibly said "WOO-HOO!"... at work, in an open office area. So yeah, a few strange looks.
Thanks for the great question, I can't wait to get part 2 wrong! 😀
Ron (a different one)
-----
a haiku...
NULL is not zero
NULL is not an empty string
NULL is the unknown
Viewing 15 posts - 1 through 15 (of 43 total)
You must be logged in to reply to this topic. Login to reply