SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 somebody help me to fix it???
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chulz90
Starting Member

Indonesia
26 Posts

Posted - 11/29/2012 :  05:38:24  Show Profile  Reply with Quote
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???


Edited by - chulz90 on 11/29/2012 05:46:09

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3380 Posts

Posted - 11/29/2012 :  05:41:20  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
>>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

Indonesia
26 Posts

Posted - 11/29/2012 :  05:48:52  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2168 Posts

Posted - 11/29/2012 :  06:19:07  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3380 Posts

Posted - 11/29/2012 :  07:07:39  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000