PreparedStatementCallback; bad SQL grammar - sql

I'm getting the following sql error in my sql command! please can anyone explain me what I'm doing wrong here!
15:20:43,686 ERROR [PageExceptionFlowInterceptor] Exception (EJBException) while executing Action [com.jkcs.khms.web.cashiering.hotelTax.HotelTaxAction] : org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * FROM (SELECT rs_qry.*, ROWNUM rn_qry FROM ( SELECT ht.htl_tax_id,
ht.hotel_id,
ht.tax_id,
ht.status,
ht.display_sequence,
t.id,
t.code,
h.hotel_name,
h.hotel_id
FROM
PMS_T_HTL_TAX ht,
CRS_T_TAX t,
CRS_T_HOTEL h WHERE ht.hotel_id IN (1) AND ht.tax_id IN (31,3,37,38,36,23,29,30,24,10,12,20,11,1,16,17,18,19,34,35,15,33,22,2,21,32) order by ht.hotel_id, ht.htl_tax_id ) rs_qry ) WHERE rn_qry BETWEEN 1 AND 10]; nested exception is java.sql.SQLException: ORA-00904: "T"."ID": invalid identifier

Your CRS_T_TAX table doesn't have a column called ID

Related

SQLite - problem with "near « ) » : syntax error"

I try here since i didn't find anything anywhere else.
I have a query which has been check by my colleagues and "teachers", but the error remains:
" near « ) » : syntax error".
The (last) query is the following one:
WITH valeur_par_ville AS
(
SELECT dep_code, com_code, AVG(valeur_fonciere) as valeur
FROM vente
JOIN bien ON bien.bien_id = vente.bien_id
JOIN commune ON commune.com_id = bien.com_id
WHERE dep_code IN (6,13,33,59,69)
GROUP BY dep_code, com_id
)
SELECT dep_code AS "Département", com_id AS "Commune", round(valeur,1) AS "Prix moyen"
FROM(
SELECT dep_code, com_nom, valeur_fonciere,
rank() OVER (PARTITION BY dep_code ORDER BY valeur_fonciere DESC) AS
rang
FROM valeur_par_ville) AS result
WHERE rang <= 3
I hope you can help me on this, because it becomes "black magic" to me!
Thanks.
I tried different ways to reach a result, but the same thing keeps going... I Checked all my data tables, updated SQLite (so PARTITION BY works on it now), reboot, checked the query little by little... No idea where it comes from.
Others colleagues (we are kind of students) managed to have a valid result with their own queries.
But for me:
" near « ) » : syntax error".
The error is coming from a different part of the code. I added CREATE TABLE statements to be able to run your code and it's failing differently.
CREATE TABLE vente(dep_code, com_code, valeur_fonciere, bien_id);
CREATE TABLE bien(bien_id, com_id);
CREATE TABLE commune(com_id);
-- your code here
The error:
Parse error near line 4: ambiguous column name: com_id
RE dep_code IN (6,13,33,59,69) GROUP BY dep_code, com_id ) SELECT dep_code AS
error here ---^
After prefixing it with a table name, there's another bunch of errors, e.g.
arse error near line 4: no such column: com_nom
(valeur,1) AS "Prix moyen" FROM( SELECT dep_code, com_nom, valeur_fonciere, ra
error here ---^
Parse error near line 4: no such column: valeur_fonciere
) AS "Prix moyen" FROM( SELECT dep_code, com_nom, valeur_fonciere, rank() OVER
error here ---^
etc.

Hive Terminal RuntimeException after query execution

I have executed this query on HIVE, using that dataset:
https://data.europa.eu/data/datasets/erasmus-mobility-statistics-2014-2019-v2?locale=en:
select i.foe, i.pn, i.massimo
from
(
SELECT m.foe, m.pn, max(m.somma) AS massimo
FROM
(
select pn, foe, sum(participants) as somma
from erasmus
WHERE foe <> "? Unknown ?" and participants>0
group by foe, pn
) as m
group by m.foe, m.pn
) as i
where i.massimo=
(
select sum(participants) as somma
from erasmus
WHERE foe <> "? Unknown ?" and participants>0 AND i.foe=foe
group by foe, pn
)
At the end of execution I get this error back:
Error: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) {"key":{"_col0":"Audio-visual techniques and media production","_col1":"AD"},"value":null}
caused by: org.apache.hadoop.hive.ql.exec.UDFArgumentException: Scalar subquery expression returns more than one row.
How can I solve this? Thank you.

Nested select statements in impala sql

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';

Can't make view from multiple table

I'm trying to learn about view in SQL. In my case, i can't execute statement to create view. Here is the statement:
CREATE VIEW VTOTALMINUTESEMPLOYEE (EMPL_KODE, EMPL_NAME,DATE_IN, TIME_IN, TIME_OUT, HASIL)
SELECT
EMPLOYEE.EMPL_KODE,
EMPLOYEE.EMPL_NAME,
ATTANDENCE.DATE_IN,
ATTANDENCE.TIME_IN,
ATTANDENCE.TIME_OUT,((TIME_OUT-TIME_IN)/60) AS "RESULT"
FROM EMPLOYEE
JOIN ATTANDENCE
ON EMPLOYEE.EMPL_KODE=ATTANDENCE.EMPL_KODE
This is the errror code :
SQL Message : -104 Invalid token
Engine Code : 335544569 Engine Message : Dynamic SQL Error SQL
error code = -104 Token unknown - line 2, column 9 SELECT
What's wrong with my code ? is there a thing that i missed ? i run the code with flamerobin. please help.
Edit: I get following error:
-104 Invalid token Engine Code : 335544569 Engine Message : Dynamic SQL Error SQL error code = -104 Token unknown - line 2, column 9
SELECT
create view emp_attd_dtls
as
select
emp.emp_id,
t.empname,
attend_dateout,
attend_datein,
attend_timein,
attend_timeout
from employee emp
inner join emp_attend t on emp.emp_id =t.emp_id

Advantage Database 8.1 SQL IN clause

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> )