473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQL Addition Problem

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 AnnualRetailPrice (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_manualsales.

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.annualRP", 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 1316
ck9663
2,878 Expert 2GB
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 AnnualRetailPrice (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_manualsales.

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.annualRP", 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
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...
2
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...
24
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...
34
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...
7
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...
3
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,...
2
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. ...
5
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.