Nageswara Rao Eluri
Nageswara Rao Eluri

Reputation: 11

Can any find the solution for this Error in IBM DB2?

%sql select Name_of_School, Safety_Score from SCHOOLS where \ Safety_Score= (select MAX(Safety_Score) from SCHOOLS)

i am trying to execute this query i got the message.

Upvotes: 1

Views: 1866

Answers (2)

FábioRB
FábioRB

Reputation: 439

I could fix by using the %%sql structure and the double quotes :

%%sql
select MAX("Safety Score") AS MAX_SAFETY_SCORE from Chicago_SCHOOLS;

Upvotes: 0

Paul Vernon
Paul Vernon

Reputation: 3911

SQL0206N is this error message https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.messages.sql.doc/com.ibm.db2.luw.messages.sql.doc-gentopic1.html#sql0206n

SQL0206N name is not valid in the context where it is used.

This error can occur in the following cases:

For an INSERT or UPDATE statement, the specified column is not a column of the table, or view that was specified as the object of the insert or update.

For a SELECT or DELETE statement, the specified column is not a column of any of the tables or views identified in a FROM clause in the statement.

among other cases.

I.e. Column SAFETY_SCORE does not exist in your table. Maybe the column is "Safety_Score" or "Safety Score" or some other name.

If the column name is not in UPPER CASE in your table, you will need to surround it in double quotes.

Upvotes: 1

Related Questions