Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Variant order 1


Variant order 1

Author
Message
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10700 Visits: 11991
Cadavre (11/30/2011)
Cadavre (11/30/2011)
Got it wrong because I believe it should say "v3 = v2" not "v2 = v3"


L' Eomot Inversé (11/30/2011)
wloong (11/29/2011)
I agreed!

From the programming logic, "v2 = v3" could not be displayed! In fact, the right answer should be "None of the above". If the editor admit that it is a typo mistake, then both "v2 = v3" and "None of the above" should be correct in order to be fair.

There isn't a typo. The select statement as written can't return v2=v3 in any of ths ecolumns of the resulting row: as you yourself state, the programming logic does not permit v2 = v3 to be displayed, so how could it imaginably be correct to say it return v2 = V3 in one of the columns?

If you run the code you will certaily see that "none of the above" is not the correct answer, because it returns one of the rows listed.


Yes Tom, but the "correct" answer states v2=v3 not v3=v2.


I replied too quickly before, didn't cover all bases before getting it wrong. I knew there wasn't a typo in the question, and didn't consider the possibility of one in the answer so didn't compare the anser with the options in the question. Thus compounding my error - the misprint was bad enough, then saying there wasn't one was worse. Mea maxima culpa Blush
The only consolation is that it didn't affect anyone's score - as is made clear by the image you attached, 51% of people got it right and were recognised as having it right even though the option they chose didn't match the row given in the answer.
Must check more carefully before rplying in future Blush

Tom

Cadavre
Cadavre
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2594 Visits: 8436
L' Eomot Inversé (11/30/2011)
I replied too quickly before, didn't cover all bases before getting it wrong. I knew there wasn't a typo in the question, and didn't consider the possibility of one in the answer so didn't compare the anser with the options in the question. Thus compounding my error - the misprint was bad enough, then saying there wasn't one was worse. Mea maxima culpa Blush
The only consolation is that it didn't affect anyone's score - as is made clear by the image you attached, 51% of people got it right and were recognised as having it right even though the option they chose didn't match the row given in the answer.


Hmm, I can't view the original question now so can't see the original options but I'm sure the reason I selected "None of the above" was because the option that most closely resembled the answer stated v2=v3 not v3=v2.

Never mind, the explanation was good :-D


Forever trying to learn

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/



If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...

(*) Missing rows with nolock
(*) Allocation order scans with nolock
(*) Consistency issues with nolock
(*) Transient Corruption Errors in SQL Server error log caused by nolock
(*) Dirty reads, read errors, reading rows twice and missing rows with nolock


Craig Wilkinson - Software Engineer
LinkedIn
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10700 Visits: 11991
Cadavre (11/30/2011)
L' Eomot Inversé (11/30/2011)
I replied too quickly before, didn't cover all bases before getting it wrong. I knew there wasn't a typo in the question, and didn't consider the possibility of one in the answer so didn't compare the anser with the options in the question. Thus compounding my error - the misprint was bad enough, then saying there wasn't one was worse. Mea maxima culpa Blush
The only consolation is that it didn't affect anyone's score - as is made clear by the image you attached, 51% of people got it right and were recognised as having it right even though the option they chose didn't match the row given in the answer.


Hmm, I can't view the original question now so can't see the original options but I'm sure the reason I selected "None of the above" was because the option that most closely resembled the answer stated v2=v3 not v3=v2.

Never mind, the explanation was good :-D

My God, I must be going crazy.

A big apology from me to everyone. Blush Blush Blush Blush Blush Blush

The typo in the answer is matched by the typo in the question. Not the bit of the question I could see in the newsletter (it doesn't show me the bits not visible to me on the website, which Of course I should have noticed Blush Blush, but as you have pointed out it soes in the bit I could see by looking at the numbers of responses!)

The only correct answer was "none of the above"!

I'll ask Steve to fix it - so far I've asked him to change the answer and add version info to the question, now I'm asking him for another change. I guess he will award points back.

Tom

callie97
callie97
SSC Eights!
SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)

Group: General Forum Members
Points: 869 Visits: 81
I got this question 'wrong' because the result of my query came back with v3 = v2, not v2 = v3. The value in the result set is a text value. That means that 'v3 = v2' is not the same as 'v2 = v3'. While mathematically it is the same, we are talking about the value of the result set as a text field. If you had not used the comparison as the returned set and had instead used Adam, Betty, Charlie or Apple, Banana, Grape to indicate which When clause had been validated as being true it would be very clear that Betty does not equal Banana. Or, if the when clause that evaluated to true was the percentage of your raise, then you are saying you would be happy with 1.0% instead of 10% because as you pointed out, it doesn't effect anyone's points if they choose None of the Above instead of the row with the typo.
I've chosen wrong answers before because of small mistakes like this so I check my result set very carefully with the choices. If this had been code that had gone to production with a small typo in the When clause, it can make for even bigger issues.
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10700 Visits: 11991
callie97 (11/30/2011)
I got this question 'wrong' because the result of my query came back with v3 = v2, not v2 = v3. The value in the result set is a text value. That means that 'v3 = v2' is not the same as 'v2 = v3'. While mathematically it is the same, we are talking about the value of the result set as a text field. If you had not used the comparison as the returned set and had instead used Adam, Betty, Charlie or Apple, Banana, Grape to indicate which When clause had been validated as being true it would be very clear that Betty does not equal Banana. Or, if the when clause that evaluated to true was the percentage of your raise, then you are saying you would be happy with 1.0% instead of 10% because as you pointed out, it doesn't effect anyone's points if they choose None of the Above instead of the row with the typo.
I've chosen wrong answers before because of small mistakes like this so I check my result set very carefully with the choices. If this had been code that had gone to production with a small typo in the When clause, it can make for even bigger issues.

You are right, there wa a typo in the option list as well as in the answer. It was absolutely stupid of me to miss that when checking as a result of the first comment this morning, and it does indeed affect people's points.

Steve will be correcting it and awarding points to people who lost them through my errors.

Tom

TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10700 Visits: 11991
rfr.ferrari (11/30/2011)
good question and explanation!!!!

thanks Tom!!!


But terrible answer!!

Tom

Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36066 Visits: 18736
The question now reader:
====
Assuming you have a database called playpen on SQL Server 2008 and above, what is the resul of the select statement in the following code?

use playpen
go
begin
declare
@v1 sql_variant = cast ('15.00' as float(53)),
@v2 sql_variant = cast ('15.00' as decimal(18,4)),
@v3 sql_variant = cast ('15' as tinyint),
@v4 sql_variant = cast ('00:00:15.00' as time)

select
case when @v1 > @v2
then 'v1 > v2'
when @v2 > @v1
then 'v2 > v1'
else 'v2 = v1'
end,
case when @v1 > @v3
then 'v1 > v3'
when @v3 > @v1
then 'v3 > v1'
else 'v3 = v1'
end,
case when @v2 > @v3
then 'v2 > v3'
when @v3 > @v2
then 'v3 > v2'
else 'v2 = v3'
end,
case when @v1 > @v4
then 'v1 > v4'
when @v4 > @v1
then 'v4 > v1'
else 'v4 = v1'
end
end


====
And the answers corrected to:
A: v2 = v1, v3 = v1, v2 = v3, v4 = v1
B: error indicating float and time are incompatible
C: v1 > v2, v1 > v3, v3 > v2, v4 > v1
D: v1 > v2, v1 > v3, v2 = v3, v4 > v1
E: v2 = v1, v1 > v3, v2 > v3, v1 > v4
F: none of the above
====

v2=v3 matches in answers A and D

Points have been awarded back to everyone to this point.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
EL Jerry
EL Jerry
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3914 Visits: 1337
Tom,

In the e-mail newsletter the QotD did not state it was for SQL Server 2008 and later, so I tested under SQL Server 2005 (the only version I have available to use), which would not allow me to run it because "you cannot assign a default value to a local variable", so i chose "None of the above" just to find out it was meant to be run under SQLS 2K8.

Just make sure the specifics are included in the newsletter.

Thank you,
GG.

"El" Jerry.

"A watt of Ottawa" - Gerardo Galvan

To better understand your help request, please follow these best practices.
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8319 Visits: 11550
Gerardo Galvan Castro (11/30/2011)
In the e-mail newsletter the QotD did not state it was for SQL Server 2008 and later, so I tested under SQL Server 2005 (the only version I have available to use), which would not allow me to run it because "you cannot assign a default value to a local variable", so i chose "None of the above" just to find out it was meant to be run under SQLS 2K8.

I'd say, with both SQL Server 2008 and SQL Server 2008R2 released and SQL Server 2012 around the corner, it is safe to assume that question are about SQL Server 2008/2008R2 unless specified otherwise.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10700 Visits: 11991
Gerardo Galvan Castro (11/30/2011)
Tom,

In the e-mail newsletter the QotD did not state it was for SQL Server 2008 and later, so I tested under SQL Server 2005 (the only version I have available to use), which would not allow me to run it because "you cannot assign a default value to a local variable", so i chose "None of the above" just to find out it was meant to be run under SQLS 2K8.

Just make sure the specifics are included in the newsletter.

Thank you,
GG.

I should have included the version information in the original question. I didn't, so it didn't get into the newsletter - and everyone who answered up to about 10 minutes ago (when the question on the website was corrected) didn't get any version information whichever way the came to the question. My fault, and no valid excuses.

But it's a good idea if coming from the newsletter to check that the version on teh website is the same - errare est humanum and all that, and corrections can be applied to the website but can't be applied to the newsletter once it's gone out.

Tom

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