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.
Author |
Topic |
chulz90
Starting Member
26 Posts |
Posted - 2012-11-29 : 05:38:24
|
i'm having trouble now, can you help me to fix it please???Item TableItem QtyBR_001 100MR tableMR_Number --Date-- --Item-- --Status MR--MR_001 --26/11/12-- --BR_001-- --Approved--MR_002 --27/11/12-- --BR_001-- --Approved--MR_003 --28/11/12-- --BR_001-- --Approved--MR_004 --29/11/12-- --BR_001-- --Approved--MR_line tableMR_Number --Item-- Qty RequestMR_001 --BR_001-- 50MR_002 --BR_001-- 30MR_003 --BR_001-- 40MR_004 --BR_001-- 70DO tableDO_Number --MR_Number --Date --To Location --Status DODO_001 --MR_001 --26/11/12 --Area 1 --ApprovedDO_002 --MR_002 --27/11/12 --Area 2 --ApprovedDO_003 --MR_003 --28/11/12 --Area 3 --ApprovedDO_line table (This the answer)DO_Number --Item --Qty NeededDO_001 --BR_001 --5DO_002 --BR_001 --3DO_003 --BR_001 --4The case is, when i generate new DO_Number below:DO_Number --MR_Number --Date --To Location -- StatusDO_004 -- MR_004 --29/11/12 --Area 4 --Approvedwhen DO_004 booked item BR_001is there any query to show DO_Line table above "BASED ON" DO_004 because DO_004 have MR_004 which is it cointain item BR_001.please help me??? |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-11-29 : 05:41:20
|
>>is there any query to show DO_Line table above "BASED ON" DO_004Is that the question?What result would you expect?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
chulz90
Starting Member
26 Posts |
Posted - 2012-11-29 : 05:48:52
|
quote: Originally posted by nigelrivett >>is there any query to show DO_Line table above "BASED ON" DO_004Is that the question?What result would you expect?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
the result is to show DO_Line table but i want to show it from DO_004u have an idea???? |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-11-29 : 06:19:07
|
As per my understading, you have 5 tables (Item, MR, MR_line, DO, DO_line tables)when you insert a row into DO table, then u need the previous values related to that DO_number.... right?If there is only 4 tables(Item, MR, MR_line, DO table), what is the logic for Qty in ur result?quote: DO_line table (This the answer)DO_Number --Item --Qty NeededDO_001 --BR_001 --5DO_002 --BR_001 --3DO_003 --BR_001 --4
--Chandu |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-11-29 : 07:07:39
|
select d.DO_Number , m.Item, [Qty Needed] = m.[Qty Request]from DO djoin MR_line mon d.MR_Number = m.MR_Number Are you missing a 0 off the qty needed or is it qty requested / 10 or something else?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|
|
|