October 30, 2012 at 11:44 am
craig 81366 (10/30/2012)
Lokesh Vij (10/30/2012)
USERID USERNAME SALES
------------------------------
5 XRay NULL
6 Easy 100
1 Joe 400
3 Charlie 700
2 Baker 800
4 Able 1000
Given the results of the query as stated in the question, courtesy of Lokesh, "Easy does have a Sales value"!
Yes, an argument can be made to interpret the question as the author intended - but that's not what the question asked!
Hence the model answer is incorrect.
🙂
I agree Craig. As already mentioned earlier, I did mis-interpret the answer choice.
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
October 30, 2012 at 12:15 pm
The only confusion has been pointed out by john.arnott. The alias of the "LEAD (Sales,1) OVER (ORDER BY Sales)" should have been "SalesGoal", not "Sales".
May be I am interpretting it wrongly, "the sales value for user EASY does not appear in the result" --> I thougt this means "sales value corresponding to user EASY should be NULL", which indeed is not the case 🙂
Interpreted the question wrong myself ... very easy to read as user EASY doesn't have a result appear.
October 30, 2012 at 12:49 pm
good question but the confusion is only in whether we have to answer to consider the current 'sales' column or after the query execution 'salesgoal' (which is not mentioned by mistake) column.
October 30, 2012 at 12:57 pm
john.arnott (10/30/2012)
... Let's step through the query...
Thank you, john.arnott, for your detailed explanation. No doubt there were many of us who benefitted!
October 30, 2012 at 2:44 pm
One good thing about this question, I learned about a new feature in 2012. I missed the question, like most, because I made an assumption that the author made a typo. The correct answers do not really test one's knowledge of the functionality of SQL, merely his or her reading comprehension.
It is kind of like that joke about a plane crashing on the U.S./Mexico border..what country do the survivors get buried in?
/*edited for grammar yo*/
Aigle de Guerre!
October 30, 2012 at 3:24 pm
Lokesh Vij (10/30/2012)
craig 81366 (10/30/2012)
Lokesh Vij (10/30/2012)
USERID USERNAME SALES
------------------------------
5 XRay NULL
6 Easy 100
1 Joe 400
3 Charlie 700
2 Baker 800
4 Able 1000
Given the results of the query as stated in the question, courtesy of Lokesh, "Easy does have a Sales value"!
Yes, an argument can be made to interpret the question as the author intended - but that's not what the question asked!
Hence the model answer is incorrect.
🙂
I agree Craig. As already mentioned earlier, I did mis-interpret the answer choice.
+1 :ermm:
This is a second one in a row that I got wrong. That has not happened to me in about two years.
Thanks, anyway!
October 30, 2012 at 5:40 pm
Meow Now (10/30/2012)
One good thing about this question, I learned about a new feature in 2012. I missed the question, like most, because I made an assumption that the author made a typo. The correct answers do not really test one's knowledge of the functionality of SQL, merely his or her reading comprehension.It is kind of like that joke about a plane crashing on the U.S./Mexico border..what country do the survivors get buried in?
/*edited for grammar yo*/
Always remember "making an assumption" means making an A$$ out of you and me.
October 31, 2012 at 1:24 am
bitbucket-25253 (10/30/2012)
Meow Now (10/30/2012)
One good thing about this question, I learned about a new feature in 2012. I missed the question, like most, because I made an assumption that the author made a typo. The correct answers do not really test one's knowledge of the functionality of SQL, merely his or her reading comprehension.It is kind of like that joke about a plane crashing on the U.S./Mexico border..what country do the survivors get buried in?
/*edited for grammar yo*/
Always remember "making an assumption" means making an A$$ out of you and me.
bitbucket, actually that's not the case here:
* Those who made an assumption about the question scored a point.
* Those who correctly answered the question as asked, didn't.
October 31, 2012 at 3:23 am
Hugo Kornelis (10/30/2012)
ben.norris (10/30/2012)
It doesn't state that the field is nullableFirst: It does. The CREATE TABLE script does not include a NOT NULL constraint, so the columns are all nullable.
Second: That is irrelevant. Even when the column is not nullable, operating a LEAD function on it can still result in NULL values. So every column in a result set that is calculated using LEAD will always be nullable, and that does not have to be explicitly stated.
>It does. The CREATE TABLE script does not include a NOT NULL >constraint, so the columns are all nullable.
It isn't always true and you cannot be always sure about this behavior,
because it depends on session setting SET ANSI_NULL_DFLT_ON|OFF.
MS SQL 2008 MCITP x 3
MS SQL 2012 MCSE x 2
October 31, 2012 at 3:32 am
Koen Verbeeck (10/30/2012)
Konstantin Reu (10/30/2012)
I think the question is not ready to be published. Description is not clear and have many mistakes like mentioned term "SalesGoal" but I did not find it anywhere 😀Next is
> Sales value for User Easy does NOT appear in the results
According to the task' explanation that sounds like
"SELECT UserId,UserName,LEAD (Sales,1) OVER (ORDER BY Sales) sales FROM #Users1 ORDER BY SALES"
field sales for user "Easy" will have value = 100. It is obvious and I've got this result.
I've got a question why do choice "Sales value for User Easy does NOT appear in the results," considered as correct part of answer ?!
I would like to get point back.....
The sales value for User Easy is 50. 50 is not returned in the resultset.
Hence, the sales value for user easy does not appear in the results.
Please be carefull as I when I read explanation.
Tasks' SQL statement contains expression through LEAD function.
and synonym for it is named "sales". Because of it I insist that
suggestion
"Sales value for User Easy does NOT appear in the results"
is false.
Because as You can guess column "Sales" will have value for user Easy.
And it doesn't matter what value will be in it, according to the task non null value is there 😉
PS. I understand opinion all who isn't arguing. But I consider - task should be resolved in that manner as it is described.
MS SQL 2008 MCITP x 3
MS SQL 2012 MCSE x 2
October 31, 2012 at 5:37 am
@john-2 Arnott
Thanks for the full explanation which certainly helped me understand why I could be said to have got it wrong, which I admit I could not grasp at first. I'm afraid I am in the misinterpreters camp - perhaps if the query had asked if any row contained the value 50 or some other phrasing.
October 31, 2012 at 6:21 am
Great question and discussion. Thanks.
October 31, 2012 at 6:31 am
Of course I had to read up on LEAD before answering this question. MSDN states: "Notice that because there is no lead value available for the last row of each partition, the default of zero (0) is returned.". Needless to say I got this one wrong.. I'm still working in 2008, so I'll have to wait before I can try it out. :unsure:
October 31, 2012 at 6:39 am
Dan Graveen (10/31/2012)
Of course I had to read up on LEAD before answering this question. MSDN states: "Notice that because there is no lead value available for the last row of each partition, the default of zero (0) is returned.". Needless to say I got this one wrong.. I'm still working in 2008, so I'll have to wait before I can try it out. :unsure:
Hi Dan,
The text you quote from the Books Online page on MSDN is part of the explanation of Example A. In that example, the LEAD function is used as LEAD(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS NextQuota
The third argument of the LEAD function is its default value. The description of that argument includes: "If a default value is not specified, NULL is returned". In the Books Online Example A, a default value of 0 was specified, so it is used. In the Question of the Day, no default value is specified, so NULL will be returned.
October 31, 2012 at 1:32 pm
Not sure what real world value this question would be as it does not keep the sales attached to the correct UserName and UserID. Seems like you just corrupted your output.
Viewing 15 posts - 31 through 45 (of 51 total)
You must be logged in to reply to this topic. Login to reply