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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Renaming fields

Hi I have a table with the fields given below:

Costs:

SQL SELECT

"CHANNEL_ID",

"PROD_ID",

"PROMO_ID",

"TIME_ID",

"UNIT_COST",

"UNIT_PRICE"

FROM SH.COSTS;

But these fields are creating a syn Table, what is the solution can I use AS to rename them with SQL Select or Load Statemant, can you please rename them for me so i could learn how to do it. any help will be highly appreciated,

Thanks

Khalid

Labels (1)
15 Replies
Not applicable
Author

Hi Shoham,

this perfectly works for me but if I want to convert it into Load so how would it look like, can you give any hint please.

Thanks

Or
MVP
MVP

Load "CHANNEL_ID" as [COST CHANNEL_ID],
"PROD_ID" as [COST PROD_ID],
"PROMO_ID" as [COST PROMO_ID],
"TIME_ID" as [COST TIME_ID],
"UNIT_COST" as [COST UNIT_COST],
"UNIT_PRICE" as [COST UNIT_PRICE];

SQL SELECT

"CHANNEL_ID",

"PROD_ID",

"PROMO_ID",

"TIME_ID",

"UNIT_COST",

"UNIT_PRICE"

FROM SH.COSTS;



Please note a couple of things:

1) Oracle defaults to returning all column names in UPPERCASE, so make sure you type them in UPPERCASE in your load script. You can then rename them to lowercase- for example, "PROD_ID" as [Cost_Prod_ID] will work in the Load script.

2) Square brackets are not necessary unless your names contain spaces or other problematic characters, but it's a good habit to use them anyway, so I've included them in my example. "PROD_ID" as COST PROD_ID, would have worked just fine if you'd prefer not to use brackets.

Not applicable
Author

Hi,

I have another issue arising now, which is I want to concatenate First Name and Last Name AS Name only, so I do it as like below:

THIS IS THE SCRIPT:







Customers:

SQL

SELECT

"COUNTRY_ID",

"CUST_FIRST_NAME"



& ' ' & "CUST_LAST_NAME" as

"CUST_NAME",

"CUST_CITY",

"CUST_CITY_ID",

"CUST_CREDIT_LIMIT",

"CUST_EFF_FROM",

"CUST_EFF_TO",

"CUST_EMAIL",

"CUST_FIRST_NAME",

"CUST_GENDER",

"CUST_ID",

"CUST_INCOME_LEVEL",

"CUST_LAST_NAME",



"CUST_MAIN_PHONE_NUMBER",

"CUST_MARITAL_STATUS",

"CUST_POSTAL_CODE",

"CUST_SRC_ID",

"CUST_STATE_PROVINCE",

"CUST_STATE_PROVINCE_ID",

"CUST_STREET_ADDRESS",

"CUST_TOTAL",

"CUST_TOTAL_ID",

"CUST_VALID",

"CUST_YEAR_OF_BIRTH"

FROM

SH.CUSTOMERS;



AND this is the error received when applied.

SQL Error:[Oracle][ODBC][Ora]ORA-00923: FROM keyword not found where expected

SQL Scriptline:
SQL State:S1000
Customers:

SQL SELECT "COUNTRY_ID",
"CUST_FIRST_NAME" & ' ' & "CUST_LAST_NAME" as "CUST_NAME",
"CUST_CITY",
"CUST_CITY_ID",
"CUST_CREDIT_LIMIT",
"CUST_EFF_FROM",
"CUST_EFF_TO",
"CUST_EMAIL",
"CUST_FIRST_NAME",
"CUST_GENDER",
"CUST_ID",
"CUST_INCOME_LEVEL",
"CUST_LAST_NAME",
"CUST_MAIN_PHONE_NUMBER",
"CUST_MARITAL_STATUS",
"CUST_POSTAL_CODE",
"CUST_SRC_ID",
"CUST_STATE_PROVINCE",
"CUST_STATE_PROVINCE_ID",
"CUST_STREET_ADDRESS",
"CUST_TOTAL",
"CUST_TOTAL_ID",
"CUST_VALID",
"CUST_YEAR_OF_BIRTH"


FROM SH.CUSTOMERS;

Not applicable
Author

Hi,

I have another issue arising now, which is I want to concatenate First Name and Last Name AS Name only, so I do it as like below:

THIS IS THE SCRIPT:





Customers:



SQL

SELECT

"COUNTRY_ID",

"CUST_FIRST_NAME"



& ' ' & "CUST_LAST_NAME" as

"CUST_NAME",

"CUST_CITY",

"CUST_CITY_ID",

"CUST_CREDIT_LIMIT",

"CUST_EFF_FROM",

"CUST_EFF_TO",

"CUST_EMAIL",

"CUST_FIRST_NAME",

"CUST_GENDER",

"CUST_ID",

"CUST_INCOME_LEVEL",

"CUST_LAST_NAME",



"CUST_MAIN_PHONE_NUMBER",

"CUST_MARITAL_STATUS",



"CUST_POSTAL_CODE",

"CUST_SRC_ID",

"CUST_STATE_PROVINCE",



"CUST_STATE_PROVINCE_ID",

"CUST_STREET_ADDRESS",

"CUST_TOTAL",





"CUST_TOTAL_ID",

"CUST_VALID",

"CUST_YEAR_OF_BIRTH"

FROM

SH.CUSTOMERS;





AND this is the error received when applied.

SQL Error:[Oracle][ODBC][Ora]ORA-00923: FROM keyword not found where expected

SQL Scriptline:
SQL State:S1000
Customers:

SQL SELECT "COUNTRY_ID",
"CUST_FIRST_NAME" & ' ' & "CUST_LAST_NAME" as "CUST_NAME",
"CUST_CITY",
"CUST_CITY_ID",
"CUST_CREDIT_LIMIT",
"CUST_EFF_FROM",
"CUST_EFF_TO",
"CUST_EMAIL",
"CUST_FIRST_NAME",
"CUST_GENDER",
"CUST_ID",
"CUST_INCOME_LEVEL",
"CUST_LAST_NAME",
"CUST_MAIN_PHONE_NUMBER",
"CUST_MARITAL_STATUS",
"CUST_POSTAL_CODE",
"CUST_SRC_ID",
"CUST_STATE_PROVINCE",
"CUST_STATE_PROVINCE_ID",
"CUST_STREET_ADDRESS",
"CUST_TOTAL",
"CUST_TOTAL_ID",
"CUST_VALID",
"CUST_YEAR_OF_BIRTH"


FROM SH.CUSTOMERS;



Or
MVP
MVP

Oracle does not use & for concatenation, it uses || (two pipes).

You should write your queries in an Oracle-friendly environment - for example, PL/SQL Developer - and then copy them to QlikView once you're sure they work. The issues you're asking about have nothing to do with QlikView, they're strictly Oracle SQL. QlikView's editor is not a friendly place to write SQL, as there's no parsing, auto-complete, or any of the other options you'd enjoy in an SQL editor.

Not applicable
Author

Hi,

It really helped me a lot, thanks it resolved the problem.

Regards,

Khalid