|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 1:32 AM
Points: 3,187,
Visits: 4,140
|
|
Grant Fritchey (5/28/2010) I would argue that while all three compile and run, none of them is "correct." What do you think about the syntax of the following statements?
SELECT column1 * column2 FROM table1 SELECT column1 *column2 FROM table1 SELECT column1* column2 FROM table1 SELECT column1*column2 FROM table1 Probably only the first is correct, while others are "incorrect"?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:05 PM
Points: 2,117,
Visits: 2,209
|
|
Paul White NZ (5/29/2010) Nice (but quite shocking!) question. I'm not at all embarrassed to say I got this one wrong.
Yes, Paul, thanks. I too got it wrong and am not ashamed to say so. It didn't occur to me that the first choice could be correct (as in, run without error), even if there would no doubt be a lot of criticism of the formatting from a readability standpoint.
Also, one quibble - well, more of a feature request; I suppose I should submit it to Steve as well: It seems to me that scoring the choice percents individually should be augmented, when checkboxes are presented as question choices, with the percentage of people who got the correct combination of selections correct. For example, in the current question, what percentage of people correctly picked all 3 boxes (versus how many overall picked box 1 vs box 2 vs box 3). That will give you an accurate count of who got the question wholly correct. It may be more trouble to program than it's worth, but it would be cool to see.
- webrunner
------------------- "The chemistry must be respected." - Walter White
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 2:01 AM
Points: 5,230,
Visits: 7,020
|
|
Webrunner, what you ask for is already available:
Above the percentages for the individual options is this:
Correct answers: 62% (1099) Incorrect answers: 38% (675) Total attempts: 1774
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Yesterday @ 1:47 PM
Points: 31,406,
Visits: 13,722
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
|
|
I think I wouldn't hire anybody that wrote code like that. Using * at all is bad enough.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, October 22, 2012 4:46 PM
Points: 77,
Visits: 110
|
|
lol! Too true!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 6:10 AM
Points: 1,322,
Visits: 1,070
|
|
While I got the answer right, the explanation of the answer: "The "*" Specifies that all columns are returned, so space is not necessary in between, before, or after * in a SELECT statement" doesn't explain what is happening.
The SQL Parser is using non-alphanumeric (or, possibly, reserved) characters to determine the end of each string token. It uses non-numeric characters to determine the end of numeric tokens. Thus SELECT 1FROM <table> works, but SELECT1FROM <table> doesn't.
There was probably no decision made to allow SELECT*FROM. This is probably a result of wanting to allow mathematical formulas without forcing spaces around the operator (e.g.) field1 + 2 vs field1+2. -- JimFive
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:35 AM
Points: 7,075,
Visits: 7,113
|
|
Paul White NZ (5/29/2010)
Grant Fritchey (5/28/2010) I would argue that while all three compile and run, none of them is "correct."In the same way that 2+2=5 for sufficiently large values of 2?  I have to agree with Grant. What does the formal syntax definition of a select statement specify? I believe it requires whitespace between the SELECT keyword and the select list. The fact that the T-SQL parser has a wiggle (don't know whether it was an intended feature or an unintended consequence of the handling of * in its multiply operator role, so call it a "wiggle" rather than a "feature or a "bug", although I think "bug" would really be more appropriate) which allows it to correct some incorrect syntax doesn't make that syntax correct, it just makes it usable. Of course I may have misinterpreted the BNF definition of the syntax - maybe someone should check me.
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|