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
 General SQL Server Forums
 New to SQL Server Programming
 Query

Author  Topic 

noblemfd
Starting Member

38 Posts

Posted - 2012-05-26 : 04:31:50
Am developing an application with VB and MSSQL 2000. Database is JUTA and table is Inventory
The fields are InvDate, InvID, ShelfID, IN, OUT, Type. I want it in such a way that Whenever there is no opening balance in a particular shelf, it should insert a row and populate it with the data of the other shelf with the same InvID, but make the field ‘IN’ to be zero(‘0’) and put its own shelf name.
For example, see Shelf1, Shelf2 and Shelf3 of Inv ID 000003. How do I do this.

EXPECTED OUTPUT
InvDate1 InvID IN OUT Bal Shelf Type
03/09/2000 000001 10 0 10 shelf1 BegBal
03/09/2000 000001 40 0 40 shelf 2 BegBal
03/09/2000 000001 30 0 30 shelf 3 BegBal
03/09/2000 000002 100 0 100 shelf 1 BegBal
03/09/2000 000002 0 0 0 shelf 2 BegBal
03/09/2000 000002 0 0 0 shelf 3 BegBal
04/09/2000 000001 35 0 35 shelf 1 D00001
04/09/2000 000001 20 0 20 shelf 1 D00001
04/09/2000 000002 50 0 50 shelf 3 D00001
06/09/2000 000003 0 0 0 shelf 1 BegBal
06/09/2000 000003 15 0 15 shelf 2 BegBal
06/09/2000 000003 0 0 0 shelf 3 BegBal

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-26 : 22:14:53
where are you copying data from other shelf? As I see from above, values are all 0 for other shelfs with InvID 000003

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -