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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ODBC read Fails when I try to divide columns in query itself in script editor

Hello,

I am using following query

select a,b, (a/b) as c

from table 1

But query fails with ODBC read failed message and query works fine when I remove a/b. I also tried casting the a/b as numeric but that does not work either. Is there a way I can divide the columns in sql query itself instead calculating it in Qlikview expression.?

Thank you

5 Replies
sinanozdemir
Specialist III
Specialist III

Try:

(Cast(a as int) / Cast(b as int)) As c.

Not applicable
Author

Getting the same error

Error: QVX_UNEXPECTED_END_OF_DATA: SQL##f - SqlState: 22012, ErrorCode: 1476, ErrorMsg: [Oracle][ODBC][Ora]ORA-01476: divisor is equal to zero

roger_stone
Creator III
Creator III

Well, as you should know, divide by zero will always fail, no matter what programming language/tool you're using.

So how about:

SELECT

a,

b,

a/ALT(b>0,b,1)

FROM table1

sinanozdemir
Specialist III
Specialist III

Ok. It seems like your divisor is zero.

Try this:

IsNull(Cast(a as int) / NullIf(Cast(b as int),0),0)

Of course, this is the SQL code.

PrashantSangle

Hi,

You can also use NVL() or Decode()

Or do calculation using QlikView Functions.

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 🙂