1

When I tried to query a table using this SQL code on AWS redshift:

SELECT aa.* 
FROM 
    (SELECT * FROM abc.xyz_tab1) AS aa 
WHERE 
    aa.claimnumber="H02799";

I got the following error:

ERROR: 42703: column "h02799" does not exist in aa

I even tried:

SELECT aa.* 
FROM 
    (SELECT * FROM abc.xyz_tab1) aa 
WHERE aa.claimnumber = "H02799";

SELECT aa.* 
FROM 
    (SELECT * FROM abc.xyz_tab1) AS aa 
WHERE claimnumber = "H02799";

SELECT aa.* 
FROM 
    (SELECT * FROM abc.xyz_tab1) aa 
WHERE claimnumber = "H02799";

But got the same error.

What have I missed or doing wrong here?

3
  • 3
    Use single quotes: aa.claimnumber='H02799'. Commented Jul 3, 2019 at 9:43
  • I am not sure, but this worked. I wonder is AWS redshift sensitive towards single or double quotes??? Commented Jul 3, 2019 at 9:47
  • 2
    I'm not familiar with redshift, but in ANSI SQL double quotes are used for object identifiers, and single quotes for literal strings. Commented Jul 3, 2019 at 9:50

1 Answer 1

3

In SQL, string constants need to be enclosed in single quotes '. Double quotes are used for identifiers (column, table names).

So you need:

WHERE aa.claimnumber = 'H02799';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.