|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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?
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Problem Using Sum with Join |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|