Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

SQL SELECT SYNTAX

Good day,

I have a simple question with probably a simple solution but I keep getting the following script and  error:

/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 "," is invalid here (due to grammar). contains an invalid character or it is a keyword. (It might be possible to escape it using "!"). Or a space is missing or there is one space too many.)

SQL Select

LIFNR,

GJAHR,

MONAT,

BLART,

SUM(DMBTR) AS [AMOUNT]

FROM

BSAK

WHERE GJAHR = '2018' AND (BLART = 'RE' OR BLART = 'KR')

GROUP BY LIFNR, GJAHR, MONAT, BLART;

Please assist as I cannot find the problem

Kind regards

13 Replies
prma7799
Honored Contributor III

Re: SQL SELECT SYNTAX

Query which you write looks ok just check spelling for fields ..

prma7799
Honored Contributor III

Re: SQL SELECT SYNTAX

Or try to load simple table as below

SQL Select

*

FROM

BSAK ;

Not applicable

Re: SQL SELECT SYNTAX

Thanks for the reply P M. I think I may have not been clear with my initial query. I get a script error but I do not know why, everything looks fine.

I do not want to select all records since this is a massive SAP table

Script is:

Load *

;

SQL Select

LIFNR,

GJAHR,

MONAT,

BLART,

SUM(DMBTR) AS [AMOUNT]

FROM

BSAK

WHERE GJAHR = '2018' AND (BLART = 'RE' OR BLART = 'KR')

GROUP BY LIFNR, GJAHR, MONAT, BLART;

Regards

Re: SQL SELECT SYNTAX

Did you tried your SQL query in DB once ? try to run the query once in DB and check

SQL Select

LIFNR,

GJAHR,

MONAT,

BLART,

SUM(DMBTR) AS [AMOUNT]

FROM

BSAK

WHERE GJAHR = '2018' AND (BLART = 'RE' OR BLART = 'KR')

GROUP BY LIFNR, GJAHR, MONAT, BLART

prma7799
Honored Contributor III

Re: SQL SELECT SYNTAX

Can you please share script error

Not applicable

Re: SQL SELECT SYNTAX


/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 "," is invalid here (due to grammar). contains an invalid character or it is a keyword. (It might be possible to escape it using "!"). Or a space is missing or there is one space too many.)

QVe.png

Re: SQL SELECT SYNTAX

try this

SQL Select

LIFNR,

GJAHR,

MONAT,

BLART,

SUM(DMBTR) AS [AMOUNT]

FROM

BSAK

WHERE GJAHR = '2018' AND BLART in('RE' , 'KR')

GROUP BY LIFNR, GJAHR, MONAT, BLART;

Not applicable

Re: SQL SELECT SYNTAX

Thank ypu for the reply Kushal, unfortunately this does  not work. I commented out the where clause and i still get the same error. With the where clause I get this error:

/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 "IN(" is invalid here (due to grammar). contains an invalid character or it is a keyword. (It might be possible to escape it using "!"). Or a space is missing or there is one space too many.)

SQL Select

LIFNR,

GJAHR,

MONAT,

BLART,

SUM(DMBTR) AS [AMOUNT]

FROM

BSAK

WHERE GJAHR = '2018' AND BLART in('RE' , 'KR')

GROUP BY LIFNR, GJAHR, MONAT, BLART

prma7799
Honored Contributor III

Re: SQL SELECT SYNTAX

Please check format for this

GJAHR = '2018'

BLART = 'RE'

BLART = 'KR'