0

This is what I did

select f.visits 
from pls_fy2014_pupld14a pfpa as f

and I got:

SQL Error [42601]: ERROR: syntax error at or near "AS"

This case below is working but I don't get why I cannot use 'as'

select visits 
from pls_fy2014_pupld14a pfpa
SSW
  • 31
  • 3

3 Answers3

1

Aliases always have to be put directly after the table or column name, so in your case:

SELECT pfpa.visits AS f
FROM pls_fy2014_pupld14a pfpa
Jonas Metzler
  • 4,517
  • 1
  • 5
  • 17
1

In your second query:

select visits
from pls_fy2014_pupld14a pfpa;

the pfpa appearing after the table name is an alias. Note that we can only alias a table once in SQL. In your second query:

select f.visits
from pls_fy2014_pupld14a pfpa as f

you attempting to alias pfpa a second time as f. You can't do that.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
0

You are - probably - trying to alias the table twice. AS is not mandatory, so

SELECT pfpa.visits
FROM pls_fy2014_pupld14a pfpa

is the same as:

SELECT pfpa.visits
FROM pls_fy2014_pupld14a AS pfpa

You can not add another alias f

Lennart - Slava Ukraini
  • 6,936
  • 1
  • 20
  • 32