473,833 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Addition Problem

17 New Member
I have the following within a SELECT statement:

Expand|Select|Wrap|Line Numbers
  1. :
  2.  
  3.  
  4. AnnualRP = sum(CASE WHEN Original.CampCode like '%u%' 
  5. AND(Original.CompletedCode = 24 OR Original.CompletedCode = 25) 
  6. THEN cast((adprem)*12 as money)
  7. WHEN Original.CampCode like '%u%' 
  8. AND(Original.CompletedCode <> 25 AND Original.CompletedCode <> 24) THEN 0 
  9. ELSE cast((Price)*12 as money) END) 
  10. + (Select cast(sum(annualrp) as money) as annualrp from tbl_obmi_manualsales where date = original.calldate and campcode = original.campcode and democode = original.democode) ....
  11.  
  12.  
...so essentially what I am doing is firstly creating the figure for AnnualRetailPri ce (AnnualRP) using the case statement ("if it is an upgrade campaign and a sale sum the additional premium else take the full price); then adding on any figures for manual sales (sum(annnualrp) from tbl_obmi_manual sales.

To me this seems logical, however, every row has 'null' in the resultant dataset.

I have also tried joining the table on and adding onto the end "+ ManualSales.ann ualRP", but this still returns no records.

Am I unaware of some addition rule here or some other rule?

The query works and gives figures when the addition is taken off, it's just when it's tacked onto the end it gives null values.

Any ideas or pointers please?!

Thanks

J
Apr 17 '08 #1
1 1334
ck9663
2,878 Recognized Expert Specialist
I have the following within a SELECT statement:

Expand|Select|Wrap|Line Numbers
  1. :
  2.  
  3.  
  4. AnnualRP = sum(CASE WHEN Original.CampCode like '%u%' 
  5. AND(Original.CompletedCode = 24 OR Original.CompletedCode = 25) 
  6. THEN cast((adprem)*12 as money)
  7. WHEN Original.CampCode like '%u%' 
  8. AND(Original.CompletedCode <> 25 AND Original.CompletedCode <> 24) THEN 0 
  9. ELSE cast((Price)*12 as money) END) 
  10. + (Select cast(sum(annualrp) as money) as annualrp from tbl_obmi_manualsales where date = original.calldate and campcode = original.campcode and democode = original.democode) ....
  11.  
  12.  
...so essentially what I am doing is firstly creating the figure for AnnualRetailPri ce (AnnualRP) using the case statement ("if it is an upgrade campaign and a sale sum the additional premium else take the full price); then adding on any figures for manual sales (sum(annnualrp) from tbl_obmi_manual sales.

To me this seems logical, however, every row has 'null' in the resultant dataset.

I have also tried joining the table on and adding onto the end "+ ManualSales.ann ualRP", but this still returns no records.

Am I unaware of some addition rule here or some other rule?

The query works and gives figures when the addition is taken off, it's just when it's tacked onto the end it gives null values.

Any ideas or pointers please?!

Thanks

J

Would you mind posting the entire query?

-- CK
Apr 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3439
by: Mark Dickinson | last post by:
Can anyone either reproduce or explain the following apparently inconsistent behaviours of __add__ and __mul__? The class Gaussian provides a sub-bare-bones implementation of Gaussian integers (a Gaussian integer is a complex number x+yi for which both x and y are integers): class Gaussian(object): """class representing Gaussian integers"""
2
1233
by: Derek | last post by:
I am having a problem updating the main table (2nd set of code) based on the total of all details entered (1st set of code). It seems to be off by less than a dollar. I thought it was a decimal issue but all my ctypes are set to decimal. I am resetting all my textfields to "" after adding the detail information. Any help would be appreciated. Here's the code:
24
2722
by: Alex Vinokur | last post by:
Consider the following statement: n+i, where i = 1 or 0. Is there more fast method for computing n+i than direct computing that sum? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html
34
16704
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1 - 3;
7
4783
by: Martin Strojek | last post by:
Hi, I have the following problem with developing some web site. I use Visual Studio 2003 to build a website. I tried Windows 2003 Server and switched now back to Windows XP with PWS but the error occurs in both installations. When I do a compile/build of my app and go to the browser and hit reload there comes an error:
3
2194
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters, dashes) into each variable. For just numbers, it's relatively easy: ifstream fout("s1.in"); for (a=0; a<17; a++) { fout >> data; cout << data << endl; }
2
1435
by: S. Kitty | last post by:
Hi everyone! I have a bit of a weird problem right now with the addition of a record in a subform. The database is supposed to keep track of a list of projects for a consulting company. There are a few sort criteria made by checkboxes, and the projects shown update immediately to reflect that. There are a series of companies that work is being done for, and for
5
4599
by: Mike | last post by:
Hello All, Please, if anyone can point me to the problem, I'd sure appreciate it! I am very new to VB programming and not a programmer to begin with. This is part of a Visual Basic 2005 Express Edition program to control a remote basketball scoreboard display unit. All I'm trying to do is add 5 byte variables and store the result in an integer variable. I added a Try/Catch block to take look at things. This exception occurs only when...
3
1613
by: srinivas33034 | last post by:
Hi there, my problem is i have to perform addition dyamically My req is i have 3 txt boxes.. and another text box to display total additon.. as i am entering the values in TextBox1 i want to see the updated addition performed so far in the final textbox..
0
9796
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9323
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7753
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5789
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3078
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.