1

I have a section of a larger query, which we are working on converting from SQL to postgres that is giving an error of (Error: column "CEL" does not exist) and I am not sure why as CEL is a value nota column. I get the same result if I change "CEL" to CEL.

Select id, MIN(pos) as position from perphone

where personal_phone_type = "CEL"

GROUP BY id
  • Have you tried with single quotes? `'CEL'` – Ewan Mar 09 '22 at 20:31
  • Yes but then I get the following error (ERROR: syntax error at or near "CEL" LINE 105: where personal_phone_type = 'CEL') – Jonathan Robinson Mar 09 '22 at 20:49
  • 2
    I'm going to say there is some sort of hidden character around `'CEL'`, probably after. Add the complete error message to your question, there should be another line with a pointer that shows where the parser thinks the error is. – Adrian Klaver Mar 09 '22 at 20:55
  • That looks to may have been it. I'm able to run it by itself successfully. I believe the Syntax error is coming from other parts of the query as this is only a section of a Left Join. – Jonathan Robinson Mar 09 '22 at 21:03

1 Answers1

1

"" is for quoting identifiers like columns and tables.

'' is for quoting constant values

select
  id,
  min(pos) as position
from perphone
where personal_phone_type = 'CEL'
group by id
Schwern
  • 153,029
  • 25
  • 195
  • 336