Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
paweln
Contributor III
Contributor III

Field alias in SQL doesn't work.

LOAD
REFERENCE,
QPPRC,
DM,
TM,
DMcast,
TMcast;


SQL SELECT

REFERENCE,
QPPRC,
DM,
TM,
CAST(DM as INTEGER_TYPE) as DMcast,
CAST(TM as REAL_TYPE)as TMcast
FROM database.schema.table3 ;

 

SQL part is OK for sure.  As I know, one can alias fields like that. Otherwise, how to load that field?

I get error: Field 'DMcast' not found.

 

Any ideas?

Labels (3)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

First, remove the preceding Load, so you just have an SQL SELECT and nothing else. Do you still get an error?

Probably you still get an error. And if so, it means that the SELECT syntax is not accepted by the driver that you use (ODBC or OLEDB). (The SELECT statement is not evaluated by the Qlik engine. It is sent to the DB driver for evaluation there.)

You can probably remove the Cast() call and use the Qlik functions, e.g. Num#(), to convert the field to an integer.

HIC

View solution in original post

2 Replies
hic
Former Employee
Former Employee

First, remove the preceding Load, so you just have an SQL SELECT and nothing else. Do you still get an error?

Probably you still get an error. And if so, it means that the SELECT syntax is not accepted by the driver that you use (ODBC or OLEDB). (The SELECT statement is not evaluated by the Qlik engine. It is sent to the DB driver for evaluation there.)

You can probably remove the Cast() call and use the Qlik functions, e.g. Num#(), to convert the field to an integer.

HIC

paweln
Contributor III
Contributor III
Author

Henric,

Your suggestion to check output of only SQL part helped. I aliased fields with lower and upper case letters but DBMS changed them into upper case only.  That's why my Load statement couldn't find "DMcast". "DMCAST" works.

 

BTS. All your blog posts are extremely interesting for beginners like me, thank you!:)