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 |
|
Hdiva
Starting Member
10 Posts |
Posted - 2006-01-12 : 15:29:36
|
| I have a select statement that returns records but now I need to insert several condition statements that look at the results from the first select and add additional selects. Here is the code with what I think should happen:ALTER procedure mhwrklst.sp_mhwrklst_bringit@cd char(3)as set nocount on beginIF @cd = 'ALL' SELECT A.ordernumb, A.whloc, A.move_made_flag, A.updttms, SUBSTRING(B.RUTSEQNO,0 ,7) as SEQ, SUBSTRING(B.RUTSEQNO,7 ,10) as OPR, B.PRESEQNO, B.WRKCTR, B.woopstf, B.userfld1, C.Wrkctr_desc, C.Grid_Location, C.Loc_desc, C.grid_group_code, D.l_start FROM WaitStation A with (nolock) INNER JOIN FMROUTE B with (nolock) ON A.ordernumb = B.WONO AND A.conserno = B.RUTSEQNO INNER JOIN hal_tbl_wrkctr_grid_loc C with (nolock) ON B.WRKCTR = C.Wrkctr INNER JOIN FMROUTE_Supl D with (nolock) ON B.PLNTNO = D.PLNTNO AND B.WONO = D.WONO AND B.RUTSEQNO = D.RUTSEQNO WHERE (A.whloc = 'BRINGIT') AND (A.move_made_flag = 'N') AND C.grid_group_code in ('1','2','3','4','5','6','7','8','9','LGH') ORDER BY A.updttms, B.WOOPSTF, C.Grid_LocationEND Here is what I need to add: The values NXTEQNO AND ORDERNUMB ARE RESULTS FROM THE FIRST SELECTIF rtrim(@NXTSEQNO)<> '000000' SELECT B.WRKCTR, B.Wrkctr_desc, B.Grid_Location, A.NXTSEQNO FROM FMROUTE A with (nolock) INNER JOIN hal_tbl_wrkctr_grid_loc B with (nolock) ON A.WRKCTR = B.Wrkctr where A.rutseqno = @NXTSEQNO and A.wono = @ORDERNUMBENDGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO |
|
|
Hdiva
Starting Member
10 Posts |
Posted - 2006-01-12 : 16:19:59
|
| I am going to dump it into a temp table and go from there. Thanks. |
 |
|
|
|
|
|
|
|