473,663 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

computations when doing a join

I have two tables with the same structure and need to compare the
similar rows where they exist. That's the easy part. However, I can't
figure out a way to do a calculation when a specific row only exists
in one of the tables.

Ex:
Table A
--------------
| id | value |
--------------
| 1 | 10 |
| 2 | 20 |
--------------

Table B
--------------
| id | value |
--------------
| 2 | 25 |
| 3 | 35 |
--------------

I'd like the result to reflect the sum of the values
--------------
| id | value |
--------------
| 1 | 10 |
| 2 | 45 |
| 3 | 65 |
--------------

But what I get when doing a join is
--------------
| id | value |
--------------
| 1 | 10 |
| 2 | null |
| 3 | null |
--------------

I feel like the process should be simple but haven't had any luck
using Joins or Unions to do this. Any ideas? Thanks in advance
Jul 19 '05 #1
0 911

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

Similar topics

1
1558
by: David | last post by:
Hello, all. I hope somebody in this group can either answer my questions or point me in the right direction. I write Javascript routines that do mathematical, floating point, computations. I like Javascript because a person does not have to download anything to their computer, and the source code is viewable--making it easy to download and include in a "C" program.
9
6401
by: Chris Greening | last post by:
I'm seeing a very strange problem with outer joins. The example below replicates the problem: create table data1 (dim1 integer, stat1 float); create table data2 (dim1 integer, stat2 float); insert into data1 values (1,1); insert into data1 values (1,2); insert into data1 values (2,2);
0
879
by: Josh | last post by:
I have two tables with the same structure and need to compare the similar rows where they exist. That's the easy part. However, I can't figure out a way to do a calculation when a specific row only exists in one of the tables. Ex: Table A -------------- | id | value | --------------
4
4861
by: thilbert | last post by:
All, I have a perplexing problem that I hope someone can help me with. I have the following table struct: Permission ----------------- PermissionId Permission
3
10046
by: Dam | last post by:
Using SqlServer : Query 1 : SELECT def.lID as IdDefinition, TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour FROM serveur.Data_tblDEFINITIONTABLEDECODES def, serveur.Data_tblTABLEDECODEAUNEVALEUR TDC_AUneValeur where def.TYPEDETABLEDECODES = 4
6
3052
by: jao | last post by:
My company has a product in beta which uses Postgres 7.4.3. We expect to have a code freeze for our 1.0 product in March 2005. I'd really like to use Postgres 8.x in our 1.0 product. We're especially looking forward to the background writer and tablespaces. Is the 8.0 release date known? Suppose 8.0 is released in December or January. Is it a sane thing to put 8.0 in a shipping product within the first two months of its release? I...
1
1130
by: Dan | last post by:
Hi All, Firstly my apologies. I am not really an access user so if this question seems fundamental I am sorry. I am trying to replicate this query using another programming language. Want I am in need to assistance with is merely clarification that it is doing what I think it is... <snip>...
4
292
by: Robert Dufour | last post by:
I have two classes , class1 and class2 In class1 I have Public Overload function Fct1(paramlist) as string some code end function Public overloads Function Fct1(otherparamlist) as string some code
7
2514
by: Gary Brown | last post by:
Hi, I have a computation intensive application that tries to update the display quite often. After a few seconds the window stops updating and the window goes blank. A breakpoint in the Paint event doesn't trigger. Further, if another window obscures the display while it is still working the display is blank after it is uncovered. Also, when the window is blank, the program does not
16
2627
by: techystud | last post by:
Hi, I am doing a Left Join between two views wherein the column used in the ON condition has empty string rows in the first view. while running the query the application flashes, shows #ERROR value for some of the rows and hangs. its a simple piece of code but its not working...... SELECT cstr(.), cstr(.Date) from Left outer join on trim(cstr(.)) = trim(cstr(.Date)) need help urgently...
0
8436
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
8345
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
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8634
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...
1
6186
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
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.