0
  SELECT a=1,b=2
vs
  SELECT 1 AS a, 2 AS b

enter image description here

what approach should i use ? (by best practice decisions)

Is there any advantages of one vs the other ?

Royi Namir
  • 144,742
  • 138
  • 468
  • 792

4 Answers4

4

Personally I use AS - it is more explicit and used elsewhere (table aliases).

It is also standard - using the = syntax will not work on some databases.

I don't believe there are any performance implications for using one over the other.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
2

I dont think where is a difference. But i would prefer the second approach. I think its more logical than the first.

So, i use the AS approach.

AS temporarily assigns a table column a new name. This grants the SQL developer the ability to make adjustments to the presentation of query results and allow the developer to label results more accurately without permanently renaming table columns. Source

dknaack
  • 60,192
  • 27
  • 155
  • 202
0

I use AS. It's a more SQL friendly way!

aF.
  • 64,980
  • 43
  • 135
  • 198
0

SELECT 1 AS a, 2 AS b

is common for all DBs

Nurlan
  • 673
  • 4
  • 18