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 8143445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:07:34+00:00 2026-06-06T13:07:34+00:00

i have a query that in a sub query calculates amount by dividing two

  • 0

i have a query that in a sub query calculates amount by dividing two of the columns. I get this error that i have division by zero, but actually i don’t have 0 or NULL values. Here is the query:

SELECT 
(SELECT ISNULL((IznosIni/VrednostIni),0)
from  plPlataF f1 
where plPresmetka_id in 
    (select plPresmetka_id from plPresmetka where f_vlezno=1 and Kod ='01') 
and f1.plPlataS_id=s.plPlataS_id) 
FROM plPlataS s 
WHERE plPlataH_Id = 171

when i run this query (i only concatenate the two values with ‘—‘ in between)

SELECT 
(SELECT CONVERT(NVARCHAR(20),IznosIni)+'---'+CONVERT(NVARCHAR(20),VrednostIni)
from  plPlataF f1 
where plPresmetka_id in 
    (select plPresmetka_id from plPresmetka where f_vlezno=1 and Kod ='01') 
and f1.plPlataS_id=s.plPlataS_id) 
FROM plPlataS s 
WHERE plPlataH_Id = 171

i get results :

32414.00---168.00 
37613.00---168.00 
31341.00---168.00 
49148.00---168.00 
110507.00---168.00 
36601.00---168.00 
37895.00---168.00 
59699.00---168.00 
43978.00---168.00 
50991.00---168.00 
36601.00---168.00 
48087.00---168.00 
45921.00---168.00 
59499.00---168.00 
37613.00---168.00 
37613.00---168.00 
34850.00---168.00 
33632.00---168.00 
33632.00---168.00 

There is no 0 anywhere!!!
Can someone please help i don’t understand what the problem might be.
Thanks in advance.

  • 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-06T13:07:35+00:00Added an answer on June 6, 2026 at 1:07 pm

    Since you are using ISNULL, I’m guessing this is TSQL. You should always take into account on division about the possibility of dividing by zero. You can use NULLIF for this:

    SELECT 
    (SELECT ISNULL((IznosIni/NULLIF(VrednostIni,0)),0)
    from  plPlataF f1 
    where plPresmetka_id in 
        (select plPresmetka_id from plPresmetka where f_vlezno=1 and Kod ='01') 
    and f1.plPlataS_id=s.plPlataS_id) 
    FROM plPlataS s 
    WHERE plPlataH_Id = 171
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple query that relies on two full-text indexed tables, but it
I have this query that works as desired, but it seems like there should
I have a query that uses the outputs(R1,R2) of two sub queries in order
I have a sub query that returns one column, showing as GroupType, I then
I have a query that I know can be done using a subselect, but
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM
I have a query that uses a where clause. At times, this may be
I've got a sub-select in a query that looks something like this: left outer
I have a query with a sub query in the select that needs to
I have a sub-query that just gets the sum of the number of items

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.