Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:30:03+00:00 2026-06-15T18:30:03+00:00

i have the following data but in query i got the zero problem in

  • 0

i have the following data but in query i got the zero problem in division by zero. so i want the output as given below in two forms.

drop table t;

create table t (id number(9), val1 number(9), val2 number(9));
insert into t values (1,23,2);
insert into t values (2,0,4);
insert into t values (3,7,4);
insert into t values (4,0,3);
insert into t values (5,4,6);

select sqrt(val2*val1)/val1 from t ;

SQL> /
ERROR:
ORA-01476: divisor is equal to zero

expected reults

in two forms
first query
like this

        ID SQRT(VAL2*VAL1)/VAL1
---------- --------------------
         1           .294883912
         2                    0
         3           .755928946
         4                    0
         5           1.22474487

second query
like this

       ID SQRT(VAL2*VAL1)/VAL1
---------- --------------------
         1           .294883912
         3           .755928946
         5           1.22474487
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:30:04+00:00Added an answer on June 15, 2026 at 6:30 pm

    You can use

    select sqrt(val2*val1)/val1 from t where val1 != 0;

    That will avoid the rows where val1 is 0 and so will not cause the “divide by 0” error. This should give you the second format.

    For the first format where you want to show the 0 in the output you can use a case statement in the where clause.

    select id, 
    case 
        when val1 = 0 then 0
        when val1 != 0 then sqrt(val2*val1)/val1
    end
    from t 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have the following select giving me the data I want, but I want to
Folks, we have the following problem: we've got several objects containing table data that
I have the following JSON data being returned, but for some reason, Javascript or
I have the following code, which compiles but doesn't bring back any data. Here
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have a query that I'm running on two equivalent databases, but hosted on
I've got 2 servers running SQL Server 2008, and I have the following query:
I've got a mysql query that is returning the required data, but is not
I have following data frames > head(elo) date elo 1 1921-12-18 1597 2 1922-05-14
I have following data structure (simplified): A giant list of the class TestClass public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.