473,387 Members | 1,304 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,387 software developers and data experts.

Join sum sql statement

Hi,
I have two tables.One of them is used only in run time( like temporary table). While I 'm passing from page to another, I'm using two table.
Temporary table have fields:
stok_no miktar dusulen_id
Real Table have fields;
id stok_no kalan

we assume that user inserted some data
Real table
Expand|Select|Wrap|Line Numbers
  1. id    stok_no  kalan
  2. 393   1375     10
  3. 394   1375     8 
  4.  
Temporary table
Expand|Select|Wrap|Line Numbers
  1. stok_no  miktar   dusulen_id
  2. 1375     3        393
  3. 1375     4        393
  4.  
Finally I want to show this
Expand|Select|Wrap|Line Numbers
  1. id  stok_no  kalan miktar  toplam fark
  2. 393 1375     10    6       4
  3. 394 1375     8     0       8
  4.  
I have sql statement but it doesn't work as I want

Expand|Select|Wrap|Line Numbers
  1. SELECT (D.kalan-G.miktari) kalan
  2. FROM ayniyat_fis_detay D,
  3. (SELECT dusulen_id, SUM(miktari) as miktari
  4. FROM ayniyat_fis_detay_gecici
  5. GROUP BY dusulen_id) G
  6. where D.id= G.dusulen_id
It works only id=393 because temporary table has it.
May 27 '07 #1
2 2111
pradeep kaltari
102 Expert 100+
Hi,
I guess using LEFT OUTER JOIN will solve your problem.

Regards,
Pradeep.
May 27 '07 #2
pbmods
5,821 Expert 4TB
Are you using the temporary table to store calculated values, or is your temporary table more like a 'view' of other existing tables?

If it's the latter (and in a couple of cases, even if it's the former), you might want to consider using a view instead.
May 28 '07 #3

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

Similar topics

7
by: Barry Young | last post by:
I am using Access to create a SQL query. It creates an Inner Join Query. I cut and paste the query into PL-SQL. When I try to execute the query I get an error. ORA 933 SQL command not properly...
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
7
by: stabbert | last post by:
I am attempting to join two tables together on two different unix servers. Here is some relevant info about the tables. TABLE 1 Setup ----------------------- DB2 UDB 7.2 EE
4
by: algroth | last post by:
Hi! I try to do a nested inner join by sql, but I always get an "Syntax-error in FROM-clause". The statement I try around with is: SELECT * FROM st1 INNER JOIN st2 INNER JOIN st3
14
by: Ryan | last post by:
I want to do the following SQL statement in Access. However, it won't allow me to have the secondary part of my join statement and tells me that this is not supported. OK, so Access doesn't support...
4
by: Jean-Claude | last post by:
Hi, which is the faster query ? (of course, in my case the real queries are more complex) 1/ select * from file1 a join file2 b on b.key=a.key where b.data=123 and b.name='TEST'
6
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
5
by: Sascha.Moellering | last post by:
Hi, I receive the error code SQL0338N if I try to compile this statement (part of the statement): .... left outer join lateral (SELECT * FROM LIZSYSABA.VWZL0359TBS WHERE tbs_name = CASE WHEN...
3
by: rrstudio2 | last post by:
If I have two tables and need to do a left outer join and include a where statement on the second table, it seems like the left outer join becomes an inner join. For example: Table: Names id...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...

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.