473,466 Members | 4,869 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Nulls in calculations

hi,
i ran the follow command:
select #tempra.ranumber,#tempra.amountdue,#tempquickrec.t otalrec,
#temparap.amountpaid,bal=amountdue - totalrec+amountpaid
from #tempra
left join #tempquickrec on #tempquickrec.hrr = #tempra.ranumber
left join #temparap on #temparap.ranumber = #tempra.ranumber
result:

ranumber amountdue totalrec amountpaid bal1222 $1200 $1000
Null null2222 $3000 $3000 Null null3333
$3000 $5000 $2000 0
i know null is not zero thus bal column is null.
this is because there is no corresponding record in the #temparap table
so how do i obtain the following result:
(ie Ranumber bal is not 0)

ranumber amountdue totalrec amountpaid bal1222 $1200 $1000
Null 2002222 $3000 $3000 Null 03333 $3000
$5000 $2000 0
i am using ms sql2000
thanks in advance
rashid
Jul 20 '05 #1
2 1703
bal= coalesce(amountdue.0) - coalesce(totalrec,0) +
coalesce(amountpaid,0)

Difficult to see what you are talking about as it's lost it's formatting
but that's a guess.

Nigel Rivett
www.nigelrivett.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
Hui!

select #tempra.ranumber,#tempra.amountdue,#tempquickrec.t otalrec,
#temparap.amountpaid,
bal=amountdue-isnull(totalrec,0)+isnull(amountpaid,0),
from #tempra
left join #tempquickrec on #tempquickrec.hrr = #tempra.ranumber
left join #temparap on #temparap.ranumber = #tempra.ranumber
-
exexe
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
Hi folks, I'm doing calculations based on data in a table, but the data has some zeros in the field I'm dividing by. I'm trying to write a script to replace any field with 0 or null with 1, but...
3
by: aaj | last post by:
Hi I am probably going to regret asking this because I'm sure you are going to tell me my design is bad 8-) ah well we all have to learn.... anyway I often use Nulls as a marker to see if...
6
by: mike | last post by:
I'm doing what I thought was a simple GROUP BY summary of fairly simple data and the my numbers aren't working out Some results are showing up <NULL> when I know the data is in the database ...
17
by: Raziq Shekha | last post by:
Hello everyone, SQL Server 2000. I have a database in which there are several objects which have ansi nuls and quoted identifier turned ON. Is there a way I can generate a script which: (1)...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
2
by: Steve | last post by:
I am trying to evaluate the latest occurence of a date which will go in the field titled eligibility date. Table is set up as follows and am using update query to update the eligibility date to...
1
by: PST | last post by:
Here's a problem I'm trying to deal with: I'm working on a Frontpage 2000 website for a boat handicapping system, built in Access 97. What I'm trying to accomplish is: The user enters a...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
0
by: LoopyNZ | last post by:
I'm sure this has something to do with NULLS, but I just can't get my head around this behaviour. More importantly, I can't SOLVE this behaviour, and until I do I can't have any confidence in my...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.