May 19, 2014 at 2:44 pm
Hi - I'd like to create a view where I can select one value from the previous row in the table. Can a query be written that does this? I am on SQL Server 2008. For simplicity sake, I would be selecting Info 1, Info 2, Info 3 and Info 4 from row 5 but I would like Info 5 to come from row 4, does that make sense? Please let me know if I can provide any more information. Thank you in advance for your help.
May 19, 2014 at 3:24 pm
aberndt (5/19/2014)
Hi - I'd like to create a view where I can select one value from the previous row in the table. Can a query be written that does this? I am on SQL Server 2008. For simplicity sake, I would be selecting Info 1, Info 2, Info 3 and Info 4 from row 5 but I would like Info 5 to come from row 4, does that make sense? Please let me know if I can provide any more information. Thank you in advance for your help.
Hi. You definitely need to provide more information before any code could be attempted. Remember that in set theory a table has no order. That means there is no previous or next row unless you order the unordered set.
From your vague description it sounds like maybe you are looking for a recursive cte. Try googling that and see if it is what you are looking for.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2014 at 1:15 am
aberndt (5/19/2014)
Hi - I'd like to create a view where I can select one value from the previous row in the table. Can a query be written that does this? I am on SQL Server 2008. For simplicity sake, I would be selecting Info 1, Info 2, Info 3 and Info 4 from row 5 but I would like Info 5 to come from row 4, does that make sense? Please let me know if I can provide any more information. Thank you in advance for your help.
Hi, see below if it works..for you..use self join in view
create table test
( ID INT IDENTITY(1,1),
Info1 VARCHAR(50),
Info2 VARCHAR(50),
Info3 VARCHAR(50),
Info4 VARCHAR(50),
Info5 VARCHAR(50)
)
INSERT test
SELECT '1-info1', '1-info2', '1-info3', '1-info4', '1-info5'
UNION ALL
SELECT '2-info1', '2-info2', '2-info3', '2-info4', '2-info5'
UNION ALL
SELECT '3-info1', '3-info2', '3-info3', '3-info4', '3-info5'
UNION ALL
SELECT '4-info1', '4-info2', '4-info3', '4-info4', '4-info5'
UNION ALL
SELECT '5-info1', '5-info2', '5-info3', '5-info4', '5-info5'
UNION ALL
SELECT '6-info1', '6-info2', '6-info3', '6-info4', '6-info5'
SELECT t1.ID,t1.Info1,t1.Info2,t1.info3,t1.Info4,t2.Info5
FROM test t1
LEFT JOIN test t2 ON t2.ID = t1.ID-1
May 20, 2014 at 6:25 am
I'm not sure if that would pertain or not. What I am trying to do is pull information from a table (Operation) that contains multiple operations per Work Order. The information that I am looking for will always be from the operation directly preceeding the one that I select. I want all information from the Press Operator line and only the Run information from the Press line. In most cases, I can order the table by Row Id and that will give me the correct order to get info from the preceding operation. The only probelm that will occur if I use the RowId is that some older data will be inaccurate. The data will exist, it just won't be correct but this is for a report that is only using current data. I hope this makes sense. I apologize, I have a lot of experience finding and working with SQL data, just not creating tables, etc.
May 20, 2014 at 6:46 am
aberndt (5/20/2014)
I'm not sure if that would pertain or not. What I am trying to do is pull information from a table (Operation) that contains multiple operations per Work Order. The information that I am looking for will always be from the operation directly preceeding the one that I select. I want all information from the Press Operator line and only the Run information from the Press line. In most cases, I can order the table by Row Id and that will give me the correct order to get info from the preceding operation. The only probelm that will occur if I use the RowId is that some older data will be inaccurate. The data will exist, it just won't be correct but this is for a report that is only using current data. I hope this makes sense. I apologize, I have a lot of experience finding and working with SQL data, just not creating tables, etc.
There's a link in Sean's signature to an article which describes how to set up sample data. From your description, this problem looks quite straightforward.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 20, 2014 at 8:22 am
I am attempting to follow the instructions for trying to compile some test data and I keep getting the error message 'Invalid Column Name'. I am obviously missing something. Below is a sample of what I am trying to run:
SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO)
SELECT '539561','39620','E','WI PRESSGR-CM10','20' UNION ALL
SELECT '539562','39620','E','WIPRESSOP','25' UNION ALL
SELECT '539563','39620','E','WI SAND-2','26' UNION ALL
SELECT '539564','39620','E','WI OVEN-2','30' UNION ALL
SELECT '539565','39620','E','WI PART COOLOFF','35' UNION ALL
SELECT '539566','39620','E','WI SAND-2','40' UNION ALL
SELECT '539567','39620','E','WI SAW-2','48' UNION ALL
SELECT '539568','39620','E','WI INSPECT','49' UNION ALL
SELECT '539569','39620','E','WI STAMP-1','50' UNION ALL
SELECT '539570','39620','E','WI REWORK','60' UNION ALL
May 20, 2014 at 8:38 am
aberndt (5/20/2014)
I am attempting to follow the instructions for trying to compile some test data and I keep getting the error message 'Invalid Column Name'. I am obviously missing something. Below is a sample of what I am trying to run:SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO)
SELECT '539561','39620','E','WI PRESSGR-CM10','20' UNION ALL
SELECT '539562','39620','E','WIPRESSOP','25' UNION ALL
SELECT '539563','39620','E','WI SAND-2','26' UNION ALL
SELECT '539564','39620','E','WI OVEN-2','30' UNION ALL
SELECT '539565','39620','E','WI PART COOLOFF','35' UNION ALL
SELECT '539566','39620','E','WI SAND-2','40' UNION ALL
SELECT '539567','39620','E','WI SAW-2','48' UNION ALL
SELECT '539568','39620','E','WI INSPECT','49' UNION ALL
SELECT '539569','39620','E','WI STAMP-1','50' UNION ALL
SELECT '539570','39620','E','WI REWORK','60' UNION ALL
You are missing the create table statement. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2014 at 8:43 am
I did that first. Even if I add that statement to the rest, I still receive the same error.
May 20, 2014 at 8:46 am
aberndt (5/20/2014)
I did that first. Even if I add that statement to the rest, I still receive the same error.
Since I can't see you screen it would be very helpful if you would post what you tried. Then we can help you figure out what is wrong.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2014 at 8:50 am
Here you go.
CREATE TABLE #mytable
(
ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
DateValue DATETIME,
Value DECIMAL(9,4),
YearValue INT,
MonthValue INT
)
SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO)
SELECT '539561','39620','E','WI PRESSGR-CM10','20' UNION ALL
SELECT '539562','39620','E','WIPRESSOP','25' UNION ALL
SELECT '539563','39620','E','WI SAND-2','26' UNION ALL
SELECT '539564','39620','E','WI OVEN-2','30' UNION ALL
SELECT '539565','39620','E','WI PART COOLOFF','35' UNION ALL
SELECT '539566','39620','E','WI SAND-2','40' UNION ALL
And this is the error received:
Msg 207, Level 16, State 1, Line 12
Invalid column name 'ROWID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'WORKORDER_BASE_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'WORKORDER_LOT_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'RESOURCE_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'SEQUENCE_NO'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'ROWID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'WORKORDER_BASE_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'WORKORDER_LOT_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'RESOURCE_ID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'SEQUENCE_NO'.
Again, I apologize. I am very unfamiliar with this process.
May 20, 2014 at 8:59 am
aberndt (5/20/2014)
Here you go.CREATE TABLE #mytable
(
ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
DateValue DATETIME,
Value DECIMAL(9,4),
YearValue INT,
MonthValue INT
)
SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO)
SELECT '539561','39620','E','WI PRESSGR-CM10','20' UNION ALL
SELECT '539562','39620','E','WIPRESSOP','25' UNION ALL
SELECT '539563','39620','E','WI SAND-2','26' UNION ALL
SELECT '539564','39620','E','WI OVEN-2','30' UNION ALL
SELECT '539565','39620','E','WI PART COOLOFF','35' UNION ALL
SELECT '539566','39620','E','WI SAND-2','40' UNION ALL
Your table and insert are not even close to the same thing. You define columns in your temp table but your insert uses different names. This is no different than any other table. You can't just insert whatever you want to, the table definition and columns for your insert must match.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2014 at 9:27 am
As I explained earlier, I do not have any experience creating tables. I appreciate your patience. I found enough information to successfully create the temp table. Please let me know what you would like me to do next.
May 20, 2014 at 9:43 am
aberndt (5/20/2014)
As I explained earlier, I do not have any experience creating tables. I appreciate your patience. I found enough information to successfully create the temp table. Please let me know what you would like me to do next.
Post it?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2014 at 9:50 am
ROWIDWORKORDER_BASE_IDWORKORDER_LOT_IDRESOURCE_IDSEQUENCE_NO
472609396211WI PRESSGR-NHB110
472610396211WIPRESSOP20
472611396211WI OVEN-530
472612396211WI PART COOLOFF35
472613396211WI SAND-640
472614396211WI INSPECT50
472615396211WI STAMP-160
472616396211WI REWORK70
472774396221WI SRL GRP20
472775396221WI REWORK70
472788396241WI PULL FR STK60
472789396241WI SHIPPING STK70
472790396251WI PRESS-2910
472791396251WIPRESSOP15
472792396251WI SAND-120
472793396251WI OVEN-230
472794396251WI PART COOLOFF31
472795396251WI SAND-135
472796396251WI CNCMILL GRP40
472797396251WICNCMILLOP45
472798396251WI INSPECT49
472799396251WI STAMP-150
472800396251WI REWORK60
47280139623AWI PRESSGR-OR-210
47280239623AWIORANGEOP20
47280339623AWI OVEN-330
47280439623AWI PART COOLOFF32
47280539623AWI SAW-435
47280639623AWI OD GRIND GRP50
47280739623AWI ID GRIND GRP55
47280839623AWI OD GRIND GRP60
47280939623AWI SAW-570
47281039623AWI INSPECT80
47281139623AWI STAMP-190
47281239623AWI REWORK100
47281339623BWI PRESSGR-OR-210
47281439623BWIORANGEOP20
47281539623BWI OVEN-330
47281639623BWI PART COOLOFF32
47281739623BWI SAW-435
47281839623BWI OD GRIND GRP50
47281939623BWI ID GRIND GRP55
47282039623BWI OD GRIND GRP60
47282139623BWI SAW-570
47282239623BWI INSPECT80
47282339623BWI STAMP-190
47282439623BWI REWORK100
47282539623CWI PRESSGR-OR-210
47282639623CWIORANGEOP20
47282739623CWI OVEN-330
47282839623CWI PART COOLOFF32
47282939623CWI SAW-435
47283039623CWI OD GRIND GRP50
47283139623CWI ID GRIND GRP55
47283239623CWI OD GRIND GRP60
47283339623CWI SAW-570
47283439623CWI INSPECT80
47283539623CWI STAMP-190
47283639623CWI REWORK100
472856396281WI SAW-820
472857396281WI SAND-430
472858396281WI SAW-735
472859396281WI SAW-340
472860396281WI STAMP-170
472861396281WI REWORK80
472863396291WI PRESSGR-AG220
472864396291WIPRESSOP25
472865396291WI OVEN-130
472866396291WI PART COOLOFF35
472867396291WI SAND-140
472868396291WI INSPECT45
472869396291WI STAMP-150
472870396291WI REWORK60
472871396301WI CNCROUTE GRP40
472872396301WI CNCROUTE GRP48
472873396301WICNCROUTOP49
472874396301WI SAND-250
472875396301WI STAMP-170
472876396301WI REWORK80
472881396311WI PRESSGR-AG120
472882396311WIPRESSOP25
472883396311WI OVEN-130
472884396311WI PART COOLOFF35
472885396311WI SAND-140
472886396311WI INSPECT45
472887396311WI STAMP-150
472888396311WI REWORK60
472889396321WI PRESSGR-AG220
472890396321WIPRESSOP25
472891396321WI OVEN-130
472892396321WI PART COOLOFF35
472893396321WI SAND-140
472894396321WI INSPECT45
472895396321WI STAMP-150
472896396321WI REWORK60
472899396331WI SHEAR-225
472900396331WI SAND-430
472901396331WI STAMP-150
472902396331WI REWORK60
472903396341WI SAW-730
472904396341WI SAND-440
472905396341WI STAMP-160
472906396341WI REWORK70
472907396351WI PULL FR STK30
472908396351WI SHIPPING STK40
472909396361WI PRESSGR-GR210
472910396361WIPRESSOP20
472911396361WI OVEN-230
472912396361WI PART COOLOFF35
472913396361WI SAND-240
472914396361WI INSPECT45
472915396361WI STAMP-150
472916396361WI REWORK60
472917396371WI SAW-820
472918396371WI SAND-430
472919396371WI SAW-740
472920396371WI HANDWORK70
472921396371WI STAMP-180
472922396371WI REWORK90
472923396381WI SAND-250
472924396381WI STAMP-180
472925396381WI REWORK90
472926396391WI SRL GRP20
472927396391WI REWORK70
472928396401WI SRL GRP20
472929396401WI REWORK70
472930396411WI SRL GRP20
472931396411WI REWORK70
472932396421WI PRESSGR-NHB125
472933396421WIPRESSOP30
472934396421WI OVEN-550
472935396421WI PART COOLOFF55
472936396421WI SAND-660
472937396421WI INSPECT70
472938396421WI STAMP-190
472939396421WI REWORK100
472940396431WI PRESSGR-CM910
472941396431WIPRESSOP15
472942396431WI SAND-230
472943396431WI OVEN-240
472944396431WI PART COOLOFF41
472945396431WI CNCROUTE GRP48
472946396431WI CNCROUTE GRP49
472947396431WI CNCROUTE GRP50
472948396431WICNCROUTOP51
472949396431WI SAND-260
472950396431WI SAND-170
472951396431WI INSPECT79
472952396431WI STAMP-180
472953396431WI REWORK90
472954396441WI MIX-110
472955396451WI MIX-110
472956396461WI PRESS-1120
472957396461WIPRESSOP25
472958396461WI OVEN-230
472959396461WI PART COOLOFF35
472960396461WI SAND-240
472961396461WI CNCROUT-350
472962396461WICNCROUTOP53
472963396461WI INSPECT55
472964396461WI STAMP-160
472965396461WI REWORK70
472966396471WI PRESSGR-GR220
472967396471WIPRESSOP25
472968396471WI OVEN-230
472969396471WI PART COOLOFF35
472970396471WI SAND-240
472971396471WI CNCROUT-350
472972396471WICNCROUTOP53
472973396471WI INSPECT55
472974396471WI STAMP-160
472975396471WI REWORK70
472976396481WI PRESSGR-CM1020
472977396481WIPRESSOP25
472978396481WI OVEN-230
472979396481WI PART COOLOFF31
472980396481WI SAND-140
472981396481WI INSPECT49
472982396481WI STAMP-150
472983396481WI SHIPPING55
472984396481WI REWORK60
472986396481WI SAND-227
472988396491WI SRL GRP20
472989396491WI REWORK30
473087396501WI SRL GRP20
473088396501WI REWORK70
473089396511WI PRESSGR-OR-310
473090396511WIORANGEOP20
473091396511WI OVEN-330
473092396511WI PART COOLOFF33
473093396511WI SAW-435
473094396511WI OD GRIND GRP50
473095396511WI ID GRIND GRP55
473096396511WI OD GRIND GRP60
473097396511WI SAW-370
473098396511WI INSPECT80
473099396511WI STAMP-190
473100396511WI REWORK100
473109396531WI PRESS-1110
473110396531WIPRESSOP20
473111396531WI OVEN-230
473112396531WI PART COOLOFF35
473113396531WI SAND-240
473114396531WI CNCROUT-345
473115396531WICNCROUTOP47
473116396531WI INSPECT48
473117396531WI STAMP-150
473118396531WI REWORK60
473119396541WI PRESSGR-CM1020
473120396541WIPRESSOP30
473121396541WI SAND-240
473122396541WI OVEN-250
473123396541WI PART COOLOFF51
473124396541WI SAND-260
473125396541WI CNCMILL GRP70
473126396541WICNCMILLOP75
473127396541WI INSPECT78
473128396541WI STAMP-180
473129396541WI REWORK90
473130396551WI SAW-730
473131396551WI SAND-435
473132396551WI OVEN-640
473133396551WI CNCROUT-346
473134396551WI CNCROUT-348
473135396551WI CNCROUT-350
473136396551WI SAND-260
473137396551WI SAND-180
473138396551WI STAMP-1100
473139396551WI REWORK110
473140396561WI SAW-730
473141396561WI OVEN-650
473142396561WI OVEN-655
473143396561WI CNCROUTE GRP58
473144396561WI CNCROUTE GRP59
473145396561WI CNCROUTE GRP60
473146396561WI SAND-270
473147396561WI SAND-480
473148396561WI STAMP-1100
473149396561WI REWORK110
473150396571WI MIX-110
473151396581WI PRESSGR-OR-210
473152396581WIORANGEOP15
473153396581WI OVEN-320
473154396581WI PART COOLOFF25
473155396581WI SAW-430
473156396581WI OD GRIND GRP40
473157396581WI ID GRIND GRP50
473158396581WI OD GRIND GRP60
473159396581WI SAW-370
473160396581WI DRILL GROUP80
473161396581WI DRILL GROUP85
473162396581WI INSPECT87
473163396581WI STAMP-190
473164396581WI REWORK100
47317739659AWI PRESSGR-OR-310
47317839659AWIORANGEOP20
47317939659AWI OVEN-330
47318039659AWI PART COOLOFF35
47318139659AWI SAW-440
47318239659AWI OD GRIND GRP50
47318339659AWI ID GRIND GRP70
47318439659AWI OD GRIND GRP80
47318539659AWI SAW-390
47318639659AWI INSPECT95
47318739659AWI STAMP-1100
47318839659AWI REWORK110
47318939659BWI PRESSGR-OR-310
47319039659BWIORANGEOP20
47319139659BWI OVEN-330
47319239659BWI PART COOLOFF35
47319339659BWI SAW-440
47319439659BWI OD GRIND GRP50
47319539659BWI ID GRIND GRP70
47319639659BWI OD GRIND GRP80
47319739659BWI SAW-390
47319839659BWI INSPECT95
47319939659BWI STAMP-1100
47320039659BWI REWORK110
47320139659CWI PRESSGR-OR-310
47320239659CWIORANGEOP20
47320339659CWI OVEN-330
47320439659CWI PART COOLOFF35
47320539659CWI SAW-440
47320639659CWI OD GRIND GRP50
47320739659CWI ID GRIND GRP70
47320839659CWI OD GRIND GRP80
47320939659CWI SAW-390
47321039659CWI INSPECT95
47321139659CWI STAMP-1100
47321239659CWI REWORK110
47321339659DWI PRESSGR-OR-310
47321439659DWIORANGEOP20
47321539659DWI OVEN-330
47321639659DWI PART COOLOFF35
47321739659DWI SAW-440
47321839659DWI OD GRIND GRP50
47321939659DWI ID GRIND GRP70
47322039659DWI OD GRIND GRP80
47322139659DWI SAW-390
47322239659DWI INSPECT95
47322339659DWI STAMP-1100
47322439659DWI REWORK110
47322539659EWI PRESSGR-OR-310
47322639659EWIORANGEOP20
47322739659EWI OVEN-330
47322839659EWI PART COOLOFF35
47322939659EWI SAW-440
47323039659EWI OD GRIND GRP50
47323139659EWI ID GRIND GRP70
47323239659EWI OD GRIND GRP80
47323339659EWI SAW-390
47323439659EWI INSPECT95
47323539659EWI STAMP-1100
47323639659EWI REWORK110
47323739659FWI PRESSGR-OR-310
47323839659FWIORANGEOP20
47323939659FWI OVEN-330
47324039659FWI PART COOLOFF35
47324139659FWI SAW-440
47324239659FWI OD GRIND GRP50
47324339659FWI ID GRIND GRP70
47324439659FWI OD GRIND GRP80
47324539659FWI SAW-390
47324639659FWI INSPECT95
47324739659FWI STAMP-1100
47324839659FWI REWORK110
47324939659GWI PRESSGR-OR-310
47325039659GWIORANGEOP20
47325139659GWI OVEN-330
47325239659GWI PART COOLOFF35
47325339659GWI SAW-440
47325439659GWI OD GRIND GRP50
47325539659GWI ID GRIND GRP70
47325639659GWI OD GRIND GRP80
47325739659GWI SAW-390
47325839659GWI INSPECT95
47325939659GWI STAMP-1100
47326039659GWI REWORK110
47326139659HWI PRESSGR-OR-310
47326239659HWIORANGEOP20
47326339659HWI OVEN-330
47326439659HWI PART COOLOFF35
47326539659HWI SAW-440
47326639659HWI OD GRIND GRP50
47326739659HWI ID GRIND GRP70
47326839659HWI OD GRIND GRP80
47326939659HWI SAW-390
47327039659HWI INSPECT95
47327139659HWI STAMP-1100
47327239659HWI REWORK110
47328339660AWI PRESSGR-OR-310
47328439660AWIORANGEOP20
47328539660AWI OVEN-330
47328639660AWI PART COOLOFF40
47328739660AWI OD GRIND GRP50
47328839660AWI ID GRIND GRP70
47328939660AWI OD GRIND GRP80
47329039660AWI INSPECT90
47329139660AWI STAMP-1100
47329239660AWI REWORK110
47329339660BWI PRESSGR-OR-310
47329439660BWIORANGEOP20
47329539660BWI OVEN-330
47329639660BWI PART COOLOFF40
47329739660BWI OD GRIND GRP50
47329839660BWI ID GRIND GRP70
47329939660BWI OD GRIND GRP80
47330039660BWI INSPECT90
47330139660BWI STAMP-1100
47330239660BWI REWORK110
47330339660CWI PRESSGR-OR-310
47330439660CWIORANGEOP20
47330539660CWI OVEN-330
47330639660CWI PART COOLOFF40
47330739660CWI OD GRIND GRP50
47330839660CWI ID GRIND GRP70
47330939660CWI OD GRIND GRP80
47331039660CWI INSPECT90
47331139660CWI STAMP-1100
47331239660CWI REWORK110
47331339660DWI PRESSGR-OR-310
47331439660DWIORANGEOP20
47331539660DWI OVEN-330
47331639660DWI PART COOLOFF40
47331739660DWI OD GRIND GRP50
47331839660DWI ID GRIND GRP70
47331939660DWI OD GRIND GRP80
47332039660DWI INSPECT90
47332139660DWI STAMP-1100
47332239660DWI REWORK110
47332339660EWI PRESSGR-OR-310
47332439660EWIORANGEOP20
47332539660EWI OVEN-330
47332639660EWI PART COOLOFF40
47332739660EWI OD GRIND GRP50
47332839660EWI ID GRIND GRP70
47332939660EWI OD GRIND GRP80
47333039660EWI INSPECT90
47333139660EWI STAMP-1100
47333239660EWI REWORK110
47333339660FWI PRESSGR-OR-310
47333439660FWIORANGEOP20
47333539660FWI OVEN-330
47333639660FWI PART COOLOFF40
47333739660FWI OD GRIND GRP50
47333839660FWI ID GRIND GRP70
47333939660FWI OD GRIND GRP80
47334039660FWI INSPECT90
47334139660FWI STAMP-1100
47334239660FWI REWORK110
47334339660GWI PRESSGR-OR-310
47334439660GWIORANGEOP20
47334539660GWI OVEN-330
47334639660GWI PART COOLOFF40
47334739660GWI OD GRIND GRP50
47334839660GWI ID GRIND GRP70
47334939660GWI OD GRIND GRP80
47335039660GWI INSPECT90
47335139660GWI STAMP-1100
47335239660GWI REWORK110
47335339660HWI PRESSGR-OR-310
47335439660HWIORANGEOP20
47335539660HWI OVEN-330
47335639660HWI PART COOLOFF40
47335739660HWI OD GRIND GRP50
47335839660HWI ID GRIND GRP70
47335939660HWI OD GRIND GRP80
47336039660HWI INSPECT90
47336139660HWI STAMP-1100
47336239660HWI REWORK110
47672739627AWI PRESSGR-CM120
47672839627AWIPRESSOP25
47672939627AWI SAND-226
47673039627AWI OVEN-230
47673139627AWI PART COOLOFF32
47673239627AWI SAND-233
47673339627AWI INSPECT40
47673439627AWI STAMP-150
47673539627AWI REWORK60
47881239627GWI PRESSGR-CM120
47881339627GWIPRESSOP25
47881439627GWI SAND-226
47881539627GWI OVEN-230
47881639627GWI PART COOLOFF32
47881739627GWI SAND-233
47881839627GWI INSPECT40
47881939627GWI STAMP-150
47882039627GWI REWORK60
47882139627HWI PRESSGR-CM120
47882239627HWIPRESSOP25
47882339627HWI SAND-226
47882439627HWI OVEN-230
47882539627HWI PART COOLOFF32
47882639627HWI SAND-233
47882739627HWI INSPECT40
47882839627HWI STAMP-150
47882939627HWI REWORK60
47883039627IWI PRESSGR-CM120
47883139627IWIPRESSOP25
47883239627IWI SAND-226
47883339627IWI OVEN-230
47883439627IWI PART COOLOFF32
47883539627IWI SAND-233
47883639627IWI INSPECT40
47883739627IWI STAMP-150
47883839627IWI REWORK60
47883939627JWI PRESSGR-CM120
47884039627JWIPRESSOP25
47884139627JWI SAND-226
47884239627JWI OVEN-230
47884339627JWI PART COOLOFF32
47884439627JWI SAND-233
47884539627JWI INSPECT40
47884639627JWI STAMP-150
47884739627JWI REWORK60
47885839626AWI PRESSGR-GR220
47885939626AWIPRESSOP25
47886039626AWI SAND-228
47886139626AWI OVEN-230
47886239626AWI PART COOLOFF35
47886339626AWI SAND-240
47886439626AWI SAW-250
47886539626AWI INSPECT55
47886639626AWI STAMP-160
47886739626AWI REWORK70
47886839626BWI PRESSGR-GR220
47886939626BWIPRESSOP25
47887039626BWI SAND-228
47887139626BWI OVEN-230
47887239626BWI PART COOLOFF35
47887339626BWI SAND-240
47887439626BWI SAW-250
47887539626BWI INSPECT55
47887639626BWI STAMP-160
47887739626BWI REWORK70
47889339626CWI PRESSGR-GR220
47889439626CWIPRESSOP25
47889539626CWI SAND-228
47889639626CWI OVEN-230
47889739626CWI PART COOLOFF35
47889839626CWI SAND-240
47889939626CWI SAW-250
47890039626CWI INSPECT55
47890139626CWI STAMP-160
47890239626CWI REWORK70
48056439627BWI PRESSGR-CM120
48056539627BWIPRESSOP25
48056639627BWI SAND-226
48056739627BWI OVEN-230
48056839627BWI PART COOLOFF32
48056939627BWI SAND-233
48057039627BWI INSPECT40
48057139627BWI STAMP-150
48057239627BWI REWORK60
48057339627CWI PRESSGR-CM120
48057439627CWIPRESSOP25
48057539627CWI SAND-226
48057639627CWI OVEN-230
48057739627CWI PART COOLOFF32
48057839627CWI SAND-233
48057939627CWI INSPECT40
48058039627CWI STAMP-150
48058139627CWI REWORK60
48059039627DWI PRESSGR-CM120
48059139627DWIPRESSOP25
48059239627DWI SAND-226
48059339627DWI OVEN-230
48059439627DWI PART COOLOFF32
48059539627DWI SAND-233
48059639627DWI INSPECT40
48059739627DWI STAMP-150
48059839627DWI REWORK60
48059939627EWI PRESSGR-CM120
48060039627EWIPRESSOP25
48060139627EWI SAND-226
48060239627EWI OVEN-230
48060339627EWI PART COOLOFF32
48060439627EWI SAND-233
48060539627EWI INSPECT40
48060639627EWI STAMP-150
48060739627EWI REWORK60
48060839627FWI PRESSGR-CM120
48060939627FWIPRESSOP25
48061039627FWI SAND-226
48061139627FWI OVEN-230
48061239627FWI PART COOLOFF32
48061339627FWI SAND-233
48061439627FWI INSPECT40
48061539627FWI STAMP-150
48061639627FWI REWORK60
48811739652AWI PRESSGR-AG220
48811839652AWIPRESSOP25
48811939652AWI OVEN-130
48812039652AWI PART COOLOFF35
48812139652AWI SAND-140
48812239652AWI INSPECT45
48812339652AWI STAMP-150
48812439652AWI REWORK60
48812539652BWI PRESSGR-AG220
48812639652BWIPRESSOP25
48812739652BWI OVEN-130
48812839652BWI PART COOLOFF35
48812939652BWI SAND-140
48813039652BWI INSPECT45
48813139652BWI STAMP-150
48813239652BWI REWORK60
53956139620EWI PRESSGR-CM1020
53956239620EWIPRESSOP25
53956339620EWI SAND-226
53956439620EWI OVEN-230
53956539620EWI PART COOLOFF35
53956639620EWI SAND-240
53956739620EWI SAW-248
53956839620EWI INSPECT49
53956939620EWI STAMP-150
53957039620EWI REWORK60
May 20, 2014 at 10:09 am
Below is a sample of the data I would like to work with. I would like to select the RUN data (last column) from the previous row. For example, in ROWID 612636, I would like to select the '1' from ROWID 612635. If I could create a view or something and create an additional column called PRESS_RUN, that would be ideal. I am writing a Crystal Report that requires this data.
ROWIDWORKORDER_BASE_IDWORKORDER_LOT_IDRESOURCE_IDSEQUENCE_NORUN
612633483981WI INSPECT50
612634483981WI STAMP-1100
612635483981WI PRESSGR-OR-1101
612636483981WIORANGEOP150.0833
612637483981WI OVEN-3200
612638483981WI PART COOLOFF250
612639483981WI SAW-43030
612640483981WI OD GRIND GRP4060
612641483981WI ID GRIND GRP5060
612642483981WI OD GRIND GRP6030
612643483981WI SAW-370120
612644483981WI DRILL GROUP8060
612645483981WI DRILL GROUP9060
612646483981WI PRESSGR-OR-1101
612647483981WIORANGEOP150.0833
612648483981WI OVEN-3200
612649483981WI PART COOLOFF250
612650483981WI SAW-43030
612651483981WI OD GRIND GRP4060
612652483981WI ID GRIND GRP5060
612653483981WI OD GRIND GRP6030
612654483981WI SAW-370120
612655483981WI DRILL GROUP8060
612656483981WI DRILL GROUP9060
612657483981WI REWORK200
612658483991WI INSPECT50
612659483991WI STAMP-1100
612660483991WI PRESSGR-OR-1101
612661483991WIORANGEOP150.0833
612662483991WI OVEN-3200
612663483991WI PART COOLOFF250
612664483991WI SAW-43030
612665483991WI OD GRIND GRP4060
612666483991WI ID GRIND GRP5060
612667483991WI OD GRIND GRP6030
612668483991WI SAW-370120
612669483991WI DRILL GROUP8060
612670483991WI DRILL GROUP9060
612671483991WI PRESSGR-OR-1101
612672483991WIORANGEOP150.0833
612673483991WI OVEN-3200
612674483991WI PART COOLOFF250
612675483991WI SAW-43030
612676483991WI OD GRIND GRP4060
612677483991WI ID GRIND GRP5060
612678483991WI OD GRIND GRP6030
612679483991WI SAW-370120
612680483991WI DRILL GROUP8060
612681483991WI DRILL GROUP9060
612682483991WI REWORK200
Viewing 15 posts - 1 through 15 (of 35 total)
You must be logged in to reply to this topic. Login to reply