|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:35 AM
Points: 7,078,
Visits: 7,119
|
|
Amusing and fairly easy question.
The misprints in the explanation may have left some people confused. All three alias forms are wrong (1st missing "= <", second and third bpth missing "alias").
edit: I can make typos too. Fixed.
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, March 14, 2013 9:22 PM
Points: 1,289,
Visits: 407
|
|
| Good puzzler - thanks. Nice coverage of different scenarios.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 2:04 AM
Points: 1,968,
Visits: 1,819
|
|
Tom.Thomson (9/13/2011) Amusing and fairly easy question.
The misprints in the explanation may have left some people confused. All three alias forms are wrong (1st missing "= <", second and third bpth missing "alias").
edit: I can make typos too. Fixed. Unfortunately, the editor to contribute with a question, sometime, changes the text both in the question and more often in the explanation. The explanation was victim of this change. I think because of GREAT and LESS sign that are misinterpreted as html syntax.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 2:04 AM
Points: 1,968,
Visits: 1,819
|
|
Olga B (9/13/2011)
Ah yes, my "favorite" bit of SQL syntax select 0 [A] A fun bug to find when I accidentally delete a comma and then try to figure out what's wrong with the output of select col1 col2, col1003 from sometable
What? I can't be the only one!  Thanks for the question! My favorite syntax is
select col1 AS [newcolname/sometime user friendly col name] from sometable
Other syntax is less readable and as you wrote it may lead to unwanted bug. But maybe very usefull for code generators.
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 5:58 PM
Points: 561,
Visits: 440
|
|
Carlo - absolutely that is confusing. When I intend to alias the column, I prefer to use [ColumnName] = col1 syntax, which aligns all my column names nicely.
The problem arises when I lose the comma by accident, and SQL turns col2 into an alias for col1, thus messing up my output.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: 2 days ago @ 1:06 PM
Points: 469,
Visits: 192
|
|
Interesting question and took quite sometime to figure out and also learnt along the way.
Thank you.
|
|
|
|