'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.
- ibm_db_sa://rbm44299:***@dashdb-txn-sbox-yp-lon02-04.services.eu-gb.bluemix.net:50000/BLUDB (ibm_db_dbi.ProgrammingError) ibm_db_dbi::ProgrammingError: SQLNumResultCols failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL0206N "SAFETY_SCORE" is not valid in the context where it is used. SQLSTATE=42703 SQLCODE=-206 [SQL: select Name_of_School, Safety_Score from SCHOOLS where Safety_Score= (select MAX(Safety_Score) from SCHOOLS)] (Background on this error at: http://sqlalche.me/e/f405)
Solution 1:[1]
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.
Solution 2:[2]
I could fix by using the %%sql structure and the double quotes :
%%sql
select MAX("Safety Score") AS MAX_SAFETY_SCORE from Chicago_SCHOOLS;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |
Solution 2 | Andronicus |