MATCH_RECOGNIZE - ORA-00933: SQL command not properly ended - sql

with curse as (select luna,an,valoare from cursl where moneda='eur')
SELECT *
FROM curse MATCH_RECOGNIZE (
ORDER BY an,luna
MEASURES strt.an as start_an, strt.luna as start_luna,
strt.valoare as euro_inc,LAST(scade.valoare) as euro_sf,
count(*) as nr_luni,
strt.valoare-LAST(scade.valoare) as dif
ONE ROW PER MATCH
PATTERN (strt scade{3,})
DEFINE
scade AS scade.valoare < PREV(scade.valoare)
) a
ORDER BY a.start_an,a.start_luna;
when running this I receive :
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"

According to Oracle-Base:
Oracle 12c has added the MATCH_RECOGNIZE clause

Related

Not able to use pivot function in oracle sql develope

this is the table which I need to pivot(age range must be an attribute and percentage as its row)
[1]: https://i.stack.imgur.com/TyQpV.jpg
already coded:
SELECT SECOND_RESPONSE, 25-30, 30-35, 18-25, 45-50, 40-45, 35-40, 55-60 FROM
(SELECT SECOND_RESPONSE FROM SEC_ANALYSIS_AGE)
PIVOT
(
MAX(PERCENTAGE) FOR FIRST_RESPONSE IN (25-30, 30-35, 18-25, 45-50, 40-45, 35-40, 55-60)
) AS PIV;
Output
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Error at Line: 24 Column: 3
I would recommend an include FIRST_RESPONSE, PERCENTAGE columns select statement. Would be this one:
SELECT * FROM
(SELECT SECOND_RESPONSE, FIRST_RESPONSE, PERCENTAGE FROM SEC_ANALYSIS_AGE)
PIVOT
(
MAX(PERCENTAGE) FOR FIRST_RESPONSE IN ('25-30' as "25-30", '30-35' as "30-35", '18-25' as "18-25", '45-50' as "45-50", '40-45' as "40-45", '35-40' as "35-40", '55-60' as "55-60")
)
thanks

Problematic syntax error near ")" at line 14: SQL statement - SAP Hana

I am sure that you are used to this question but nonetheless I am having trouble with my SQL script. It is very frustrating.
When I execute the SQL against the SAP Hana database, I continuously receive this error:
Errors occurred while executing the SQL statement: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near ")": line 14 col 35
Let me present the SQL concerned here:
SELECT
BKPF.BKTXT, BKPF.MONAT, BSEG.BELNR, BSEG.BUKRS, BSEG.DMBTR, BSEG.GJAHR, BSEG.MANDT, BSEG.PRCTR, BSEG.SAKNR, CEPCT.KTEXT, CEPCT.LTEXT, SKAT.MCOD1, SKAT.TXT20, SKAT.TXT50
FROM
SAPPR1.BSEG
INNER JOIN SAPPR1.BKPF ON BSEG.GJAHR = BKPF.GJAHR
INNER JOIN SAPPR1.CEPCT ON BSEG.PRCTR = CEPCT.PRCTR
INNER JOIN (SELECT
SAKNR, TXT20, TXT50, MCOD1
FROM
SAPPR1.SKAT
WHERE
SPRAS not LIKE '%[a-z0-9 .]%' ) AS SKAT_SUB ON BSEG.SAKNR = SKAT_SUB.SAKNR
WHERE
BKPF.MONAT = (SELECT Month('?')-1)
AND (BSEG.GJAHR = (SELECT Year('?')-1 HAVING Month('?')-1 < 4) OR BSEG.GJAHR = (SELECT Year('?') HAVING Month('?')-1 > 3))
AND BSEG.MANDT = ?
;
Unlike other DBMS HANA does not support selecting records out of nothing.
A SELECT without a FROM is not valid.
In order to create a single-row set one can use the DUMMY table.
SELECT current_date FROM DUMMY;
creates the single-row set with the result of the function expression.
Having said that, for comparisons a set is not required. Instead the function can be directly put into the expression:
WHERE
BKPF.MONAT = (MONTH(?)-1)
Also note that for string typed bind variables no quotation marks are required or allowed.

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

Simple SQL command not properly ended [duplicate]

This question already has answers here:
SQL Oracle LEFT JOIN and SUBQUERY error: ORA-00905: missing keyword
(2 answers)
Closed 9 months ago.
I have the following query:
SELECT *
FROM DELUSR.AGREEMENT AS agreement
WHERE agreement.MASTER_AGGREMENT_ID = 4;
After trying to run it, I get this error:
Error code 933, SQL state 42000:
ORA-00933: SQL command not properly ended
Line 1, column 1
Execution finished after 0 s, 1 error(s) occurred.
I am not sure how to decode this error message. The statement looks fine to me. Any insights into whats wrong with it?
Oracle accepts no AS for table aliases:
SELECT * FROM DELUSR.AGREEMENT agreement WHERE agreement.MASTER_AGGREMENT_ID = 4;

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