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
 somebody help me to fix it???

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 Table
Item Qty
BR_001 100

MR table
MR_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 table
MR_Number --Item-- Qty Request
MR_001 --BR_001-- 50
MR_002 --BR_001-- 30
MR_003 --BR_001-- 40
MR_004 --BR_001-- 70

DO table
DO_Number --MR_Number --Date --To Location --Status DO
DO_001 --MR_001 --26/11/12 --Area 1 --Approved
DO_002 --MR_002 --27/11/12 --Area 2 --Approved
DO_003 --MR_003 --28/11/12 --Area 3 --Approved

DO_line table (This the answer)
DO_Number --Item --Qty Needed
DO_001 --BR_001 --5
DO_002 --BR_001 --3
DO_003 --BR_001 --4


The case is, when i generate new DO_Number below:
DO_Number --MR_Number --Date --To Location -- Status
DO_004 -- MR_004 --29/11/12 --Area 4 --Approved

when DO_004 booked item BR_001
is 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_004

Is 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.
Go to Top of Page

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_004

Is 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_004

u have an idea????
Go to Top of Page

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 Needed
DO_001 --BR_001 --5
DO_002 --BR_001 --3
DO_003 --BR_001 --4




--
Chandu
Go to Top of Page

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 d
join MR_line m
on 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.
Go to Top of Page
   

- Advertisement -