Divide by zero and nulls in Sybase?
Submitted by: AdministratorDuring processing, if a divide by zero error occurs you will not get the answer you want. If you want the result set to come back and null to be displayed where divide by zero occurs do the following:
1. select * from total_temp
2. go
field1 field2
----------- -----------
10 10
10 0
10 NULL
(3 rows affected)
1. select field1, field1/(field2*convert(int,
substring('1',1,abs(sign(field2))))) from total_temp
2. go
field1
----------- -----------
10 1
10 NULL
10 NULL
Submitted by: Administrator
1. select * from total_temp
2. go
field1 field2
----------- -----------
10 10
10 0
10 NULL
(3 rows affected)
1. select field1, field1/(field2*convert(int,
substring('1',1,abs(sign(field2))))) from total_temp
2. go
field1
----------- -----------
10 1
10 NULL
10 NULL
Submitted by: Administrator
Read Online Sybase Job Interview Questions And Answers
Top Sybase Questions
☺ | What is a Coalesce? What is the equivalent of Oracle/Db2 Coalesce Function in Sybase? |
☺ | How to pad with leading zeros an int or smallint in Sybase? |
☺ | Explain about the features of Sybase IQ? |
☺ | How can I execute dynamic SQL with ASE in Sybase? |
☺ | Explain about Power Designer Data modeling software? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |