%%sql
Select Per_capita_Income, Community_Area_Name
from CENSUS_DATA
Where Per_Capita_Income < 11000;
ibm_db_sa://ztl80401:***#125f9f61-9715-46f9-9399-c8177b21803b.c1ogj3sd0tgtu0lqde00.databases.appdomain.cloud:30426/BLUDB
(ibm_db_dbi.ProgrammingError) ibm_db_dbi::ProgrammingError: SQLNumResultCols failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL0007N The statement was not processed because a character that is not supported in SQL statements was included in the SQL statement. Invalid character: "\". Text preceding the invalid character: "ame from CENSUS_DATA". SQLSTATE=42601 SQLCODE=-7
[SQL: Select Per_capita_Income, Community_Area_Name
from CENSUS_DATA
Where Per_Capita_Income < 11000;]
(Background on this error at: http://sqlalche.me/e/13/f405)
Hello,
I can't get this query to pull the Country Area names where the Per capita Income is less than 11000. what is wrong with my query? I am using Jupyter Notebooks and my database is DB2. Please help. thanks!
Related
When I try to import teradata data with a where in the sql statement I get the following error
clients<-dbGetQuery(con, "SELECT * from clients where year(cl_dataentrada) = 2018")
Error in new_result(connection#ptr, statement) :
nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]Teradata DatabaseSyntax error: expected something between the 'where' keyword and the 'year' keyword.
clients<-data.frame(clients)
I've also tried:
clients<- dbSendQuery(con, "SELECT * from clients where year(cl_dataentrada) = 2018")
Error in new_result(connection#ptr, statement) :
nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]Teradata DatabaseSyntax error: expected something between the 'where' keyword and the 'year' keyword.
Also in a sql chunk :
SELECT * from clients where year(cl_dataentrada) = 2018
Error in new_result(connection#ptr, statement) :
nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]Teradata DatabaseSyntax error: expected something between the 'where' keyword and the 'year' keyword.
Failed to execute SQL chunk
As Shiva Prakash suggested this finally works:
clients<-dbGetQuery(con, "SELECT * from clients where extract(year from cl_dataentrada)=2018")
It was an error because the function year is an odbc function not Teradata.
Thank you.
I have a question concern check a variable if is in a list with SQL
Here my request :
select * from states where status in ["Cancelled"", "Won"] limit 10000
But I get this error : 42601: syntax error at or near "["
any idea please?
thnanks
Use single quotes and "()" not "[]".
select *
from states
where status in ('Cancelled', 'Won')
limit 1000
I have the following SQL query in impala
SELECT currentdate,close
FROM ( SELECT * FROM spyprice)
Where currentdate between '2015-01-16' and '2016-06-17';
And it is giving me the error:
Starting Impala Shell without Kerberos authentication
ERROR: AnalysisException: Syntax error in line 15:
WHERE currentdate BETWEEN '2015-01-16' and '2016-06-17'
^
Encountered: WHERE
Expected: AS, DEFAULT, IDENTIFIER
CAUSED BY: Exception: Syntax error
Anyone knows what's going on?
Thanks in advance!
#James Xiang The right syntax of the query statement is :
SELECT a.currentdate, a.close FROM
(
SELECT * FROM spyprice
) a
Where a.currentdate between '2015-01-16' and '2016-06-17';
I ran the following and query and got the following error. Please see that error message mentions the column name (platform) that it thinks is not there. weird.
hive -S -e 'select * from devices.device_app_action where ds= '20160511'
AND platform= 'ios' limit 3;'
FAILED: SemanticException [Error 10004]: Line 1:73 Invalid table alias or column reference 'ios': (possible column names are: duid, id, dt, app, platform, app_level, tier1, tier2, tier3, tier4, tier5, tier6, first_geo, first_v, first_lang, total_events, min_ats, max_ats, ds)
Its telling me the column platform does not exist and its there in the list
could be you have to enclose the query in proper quotes
'select * from devices.device_app_action where ds= "20160511" AND platform= "ios" limit 3;'
Using Advantage Database Server 8.1 I am having trouble executing a successful query. I am trying to do the following
SELECT * FROM Persons
WHERE LastName IN ('Hansen','Pettersen')
To check for multiple values in a column. But I get an error when I try to execute this query in Advantage.
Edit - Error
poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [iAnywhere Solutions][Advantage SQL Engine]Expected lexical element not found: ( There was a problem parsing the
WHERE clause in your SELECT statement. -- Location of error in the SQL statement is: 46
And here is the SQL i'm executing
select * from "Pat Visit" where
DIAG1 IN = ('43644', '43645', '43770', '43771', '43772', '43773', '43774',
'43842', '43843', '43845', '43846', '43847', '43848', '97804', '98961',
'98962', '99078')
Done
Does anyone have any Idea how I could do something similar in advantage that would be efficient as well?
Thanks
You have an extraneous = in the statement after the IN. It should be:
select * from "Pat Visit" where
DIAG1 IN ('43644', '43645', <snip> )