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 «««23456»»»

Variant order 1 Expand / Collapse
Author
Message
Posted Wednesday, November 30, 2011 6:34 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 12:05 PM
Points: 8,556, Visits: 9,047
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
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


Tom
Post #1213886
Posted Wednesday, November 30, 2011 6:40 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 2:26 PM
Points: 2,422, Visits: 7,437
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
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



Not a DBA, just 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


LinkedIn | Blog coming soon (for sufficiently large values of "soon" )!
Post #1213889
Posted Wednesday, November 30, 2011 6:54 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 12:05 PM
Points: 8,556, Visits: 9,047
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
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

My God, I must be going crazy.

A big apology from me to everyone.

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 , 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
Post #1213899
Posted Wednesday, November 30, 2011 7:07 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: Monday, September 17, 2012 7:10 AM
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.
Post #1213913
Posted Wednesday, November 30, 2011 7:13 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 12:05 PM
Points: 8,556, Visits: 9,047
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
Post #1213921
Posted Wednesday, November 30, 2011 7:15 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 12:05 PM
Points: 8,556, Visits: 9,047
rfr.ferrari (11/30/2011)
good question and explanation!!!!

thanks Tom!!!


But terrible answer!!


Tom
Post #1213924
Posted Wednesday, November 30, 2011 7:46 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 2:28 PM
Points: 33,062, Visits: 15,174
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
Post #1213950
Posted Wednesday, November 30, 2011 7:48 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 2:53 PM
Points: 3,786, Visits: 1,084
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
Post #1213952
Posted Wednesday, November 30, 2011 7:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:40 AM
Points: 5,916, Visits: 8,168
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
Post #1213961
Posted Wednesday, November 30, 2011 8:01 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 12:05 PM
Points: 8,556, Visits: 9,047
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
Post #1213963
« Prev Topic | Next Topic »

Add to briefcase «««23456»»»

Permissions Expand / Collapse