Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 NEED HELP

Author  Topic 

rluyinda
Starting Member

3 Posts

Posted - 2009-05-29 : 05:44:23
Hi am trying to validate that stockm.PHYSICAL_QUANTITY= sum(stkhstm.MOVEMENT_QUANTITY) PER PRODUCT

select Product from dbo_i_stockm
where dbo_i_stockm.Product = dbo_i_stockhistm.PRODUCT
and dbo_i_stockm.PHYSICAL_QTY <> sum(dbo_i_stockhistm.MOVEMENT_QUANTITY);

The error msg i get is:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo_i_stockhistm.PRODUCT" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo_i_stockhistm.MOVEMENT_QUANTITY" could not be bound.

Thx,
Richard Luyinda

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-29 : 05:49:06
[code]
select dbo_i_stockm.Product
from dbo_i_stockm inner join
(
select Product, MovnQty = sum(MOVEMENT_QUANTITY)
from dbo_i_stockhistm
group by Product
) as histm
on dbo_i_stockm.Product = histm.Product
where dbo_i_stockm.PHYSICAL_QTY <> histm.MovnQty
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-29 : 05:53:03
There are so many fundamental errors in your query, so I suggestion you start reading and improve your skills by visiting http://www.w3schools.com/sql/default.asp

here is your query
select		a.Product
from dbo_i_stockm AS a
inner join (
SELECT product,
sum(MOVEMENT_QUANTITY) AS MOVEMENT_QUANTITY
from dbo_i_stockhistm
group by product
) AS b ON b.PRODUCT = a.Product
where a.PHYSICAL_QTY <> b.MOVEMENT_QUANTITY


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-29 : 05:54:20

To slow. Needed to find link at www.w3schools.com/sql




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rluyinda
Starting Member

3 Posts

Posted - 2009-05-29 : 05:56:22
THX A MILLION, KH, IT WORKED!!

AM NEW TO SQL, BUT I HAVE TO MAKE IT WORK ON A PROJECT.

THX AGAIN GUY, KH.
Go to Top of Page

rluyinda
Starting Member

3 Posts

Posted - 2009-05-29 : 06:02:58
THX PESO FOR THE LINK!!

quote:
Originally posted by Peso


To slow. Needed to find link at www.w3schools.com/sql




E 12°55'05.63"
N 56°04'39.26"


Go to Top of Page
   

- Advertisement -