Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Troy1
Contributor III
Contributor III

sql command for substring a numeric value (mismatch error)

When i have string field i can do a substring like below:

substring("firstname",1,20) as "firstname"

however when i try the same command on numeric field i get mismatch error.

what is the sql command within qlikview (not a qlikview function) to substrin a numeric field.

9 Replies
preminqlik
Specialist II
Specialist II

use mid(fieldname,1,20)       

Troy1
Contributor III
Contributor III
Author

gives me error mid does not work.

Not applicable

just say substring(text(<your numeric field>),1,20)

Troy1
Contributor III
Contributor III
Author

does not work. I tried using below and it works when i do 1000 records but when it goes beyond it gives me read error,

substring(cast(PhoneNumber as VARCHAR),1,15) as phonenumber,

senpradip007
Specialist III
Specialist III

Could you upload sample qvw?

Not applicable

Substring(PhoneNumber, 1,15) as phonenumber

why don't you write like this ?

is there any error in the data so you have to cast it into varchar first ?

PrashantSangle

Hi,

If possible Post your script.

It will be better to us.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Assuming that this is a SQL command (ie after a SQL SELECT phrase), then

     substring(cast(PhoneNumber as VARCHAR(15)),1,15) as phonenumber,

or even

     cast(PhoneNumber as VARCHAR(15)) as phonenumber,

should work.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Azharyasin
Contributor
Contributor

hi

i hv a numeric data field of 3 digit and intend to use ist two digits as substring pl guide

 

thanx

 

Azharyasin