Issue
I am new to SQL and through Miss Tina Huang, I came to know Mode.com, a website that provides quite a comprehensive tutorial of SQL. I encountered this problem and dont know how to fix it, can you guys help me:
SELECT
west,
midwest,
northeast,
midwest + northeast AS "midwest_northeast_combined"
FROM tutorial.us_housing_units
Where west > "midwest_northeast_combined"
And then get a warning like this:
Looks like something went wrong with your query.
org.postgresql.util.PSQLException: ERROR: syntax error at or near "midwest"
Position: 1
Solution
"midwest_northeast_combined" column is unknown to the where clause, because in your query midwest + northeast AS "midwest_northeast_combined" evaluates after where clause ,so you have to repeat it in your where clause:
SELECT
west,
midwest,
northeast,
midwest + northeast AS "midwest_northeast_combined"
FROM tutorial.us_housing_units
Where west > midwest + northeast
Answered By - eshirvana Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.