Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 27th, 2008, 11:22 PM
rusdyrip rusdyrip is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 22 rusdyrip User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 35 m 14 sec
Reputation Power: 0
Problem Using Sum with Join

pls help me solve this problem

i have
Table StockTransaction
field:
Code |In |Out

Table StockMaster
field:
Code |Name

now i want to show Last Stock
i use this query
Code:
SELECT 
STOCKTRANSACTION.CODE,
SUM(STOCKTRANSACTION.IN-STOCKTRANSACTION.OUT) AS TOTAL
FROM STOCKTRANSACTION 
GROUP BY STOCKTRANSACTION.CODE


it's work

but what i want is display the name with other field
i use this query but shows error

Code:
SELECT 
STOCKTRANSACTION.CODE,
STOCKMASTER.NAME,
SUM(STOCKTRANSACTION.IN-STOCKTRANSACTION.OUT) AS TOTAL
FROM STOCKTRANSACTION 
INNER JOIN STOCK MASTER
ON STOCKTRANSACTION.CODE=MASTER.CODE
GROUP BY STOCKTRANSACTION.CODE


if i add group by like
Code:
GROUP BY STOCKTRANSACTION.CODE,STOCKMASTER.NAME


It's work but the result is different


sory bad english

Reply With Quote
  #2  
Old March 28th, 2008, 04:07 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
Do you want to see the last stock movement with code, name and quantity? Are these the actual tables?
Or the quantity in stock as of today with code and name?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Problem Using Sum with Join


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway