May 20, 2014 at 10:43 am
OK I get it. You are new to this. That is no problem. We can help with understanding. Did you actually read the article about how to post stuff? Did you read the part about where it discusses the reason behind doing this? It isn't because we are sadistic and want you to type countless amount of rows of data. It is so we can create these tables in our database.
You stated you have a temp table but the definition you posted doesn't match the values you posted. You came back and posted a much longer list of data. The problem is that I still don't have a temp table and the data is not in a consumable format (insert statements).
_______________________________________________________________
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 11:03 am
Yes, I read the article. When you reply with a response like 'Post It?' it was a bit unclear what you wanted me to post, the query or the results. Please clarify. Yes, the 2nd time I posted different data. I did some further reading and realized that I need to add some more data. I apologize for the confusion. Below is the query I used to generate the temporary table.
IF OBJECT_ID('tempdb..#mytable') IS NOT NULL
DROP TABLE #mytable
CREATE TABLE #mytable
(
ROWID INT NOT NULL PRIMARY KEY IDENTITY(1, 1),
WORKORDER_BASE_ID VARCHAR(30),
WORKORDER_LOT_ID VARCHAR(3),
RESOURCE_ID VARCHAR(15),
SEQUENCE_NO INT,
RUN DECIMAL(8,3)
);
SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO, RUN)
SELECT '612633','48398','1','WI INSPECT','5','0.00000000' UNION ALL
SELECT '612634','48398','1','WI STAMP-1','10','0.00000000' UNION ALL
SELECT '612635','48398','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612636','48398','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612637','48398','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612638','48398','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612639','48398','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612640','48398','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612641','48398','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612642','48398','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612643','48398','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612644','48398','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612645','48398','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612646','48398','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612647','48398','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612648','48398','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612649','48398','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612650','48398','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612651','48398','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612652','48398','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612653','48398','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612654','48398','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612655','48398','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612656','48398','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612657','48398','1','WI REWORK','20','0.00000000' UNION ALL
SELECT '612658','48399','1','WI INSPECT','5','0.00000000' UNION ALL
SELECT '612659','48399','1','WI STAMP-1','10','0.00000000' UNION ALL
SELECT '612660','48399','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612661','48399','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612662','48399','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612663','48399','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612664','48399','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612665','48399','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612666','48399','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612667','48399','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612668','48399','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612669','48399','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612670','48399','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612671','48399','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612672','48399','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612673','48399','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612674','48399','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612675','48399','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612676','48399','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612677','48399','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612678','48399','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612679','48399','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612680','48399','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612681','48399','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612682','48399','1','WI REWORK','20','0.00000000'
SET IDENTITY_INSERT #mytable OFF
Select * from #mytable
May 20, 2014 at 11:06 am
quick guess before i get back to work:
SELECT * FROM #tmp T1 LEFT OUTER JOIN #tmp T2 ON T1.[ROWID] = T2.[ROWID] -1
and we expect you to provide the data like this.
a create table definition plus some insert statements
IF OBJECT_ID('tempdb.[dbo].[#tmp]') IS NOT NULL
DROP TABLE [dbo].[#tmp]
GO
CREATE TABLE [dbo].[#tmp] (
[ROWID] INT NULL,
[WORKORDER_BASE_ID] INT NULL,
[WORKORDER_LOT_ID] VARCHAR(1) NOT NULL,
[RESOURCE_ID] VARCHAR(15) NOT NULL,
[SEQUENCE_NO] INT NULL)
INSERT INTO #tmp([ROWID],[WORKORDER_BASE_ID],[WORKORDER_LOT_ID],[RESOURCE_ID],[SEQUENCE_NO])
SELECT CONVERT(int,'472609'), CONVERT(int,'39621'),'1','WI PRESSGR-NHB1', CONVERT(int,'10') UNION ALL
SELECT '472610','39621','1','WIPRESSOP',' 20' UNION ALL
SELECT '472611','39621','1','WI OVEN-5',' 30' UNION ALL
SELECT '472612','39621','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472613','39621','1','WI SAND-6',' 40' UNION ALL
SELECT '472614','39621','1','WI INSPECT',' 50' UNION ALL
SELECT '472615','39621','1','WI STAMP-1',' 60' UNION ALL
SELECT '472616','39621','1','WI REWORK',' 70' UNION ALL
SELECT '472774','39622','1','WI SRL GRP',' 20' UNION ALL
SELECT '472775','39622','1','WI REWORK',' 70' UNION ALL
SELECT '472788','39624','1','WI PULL FR STK',' 60' UNION ALL
SELECT '472789','39624','1','WI SHIPPING STK',' 70' UNION ALL
SELECT '472790','39625','1','WI PRESS-29',' 10' UNION ALL
SELECT '472791','39625','1','WIPRESSOP',' 15' UNION ALL
SELECT '472792','39625','1','WI SAND-1',' 20' UNION ALL
SELECT '472793','39625','1','WI OVEN-2',' 30' UNION ALL
SELECT '472794','39625','1','WI PART COOLOFF',' 31' UNION ALL
SELECT '472795','39625','1','WI SAND-1',' 35' UNION ALL
SELECT '472796','39625','1','WI CNCMILL GRP',' 40' UNION ALL
SELECT '472797','39625','1','WICNCMILLOP',' 45' UNION ALL
SELECT '472798','39625','1','WI INSPECT',' 49' UNION ALL
SELECT '472799','39625','1','WI STAMP-1',' 50' UNION ALL
SELECT '472800','39625','1','WI REWORK',' 60' UNION ALL
SELECT '472801','39623','A','WI PRESSGR-OR-2',' 10' UNION ALL
SELECT '472802','39623','A','WIORANGEOP',' 20' UNION ALL
SELECT '472803','39623','A','WI OVEN-3',' 30' UNION ALL
SELECT '472804','39623','A','WI PART COOLOFF',' 32' UNION ALL
SELECT '472805','39623','A','WI SAW-4',' 35' UNION ALL
SELECT '472806','39623','A','WI OD GRIND GRP',' 50' UNION ALL
SELECT '472807','39623','A','WI ID GRIND GRP',' 55' UNION ALL
SELECT '472808','39623','A','WI OD GRIND GRP',' 60' UNION ALL
SELECT '472809','39623','A','WI SAW-5',' 70' UNION ALL
SELECT '472810','39623','A','WI INSPECT',' 80' UNION ALL
SELECT '472811','39623','A','WI STAMP-1',' 90' UNION ALL
SELECT '472812','39623','A','WI REWORK',' 100' UNION ALL
SELECT '472813','39623','B','WI PRESSGR-OR-2',' 10' UNION ALL
SELECT '472814','39623','B','WIORANGEOP',' 20' UNION ALL
SELECT '472815','39623','B','WI OVEN-3',' 30' UNION ALL
SELECT '472816','39623','B','WI PART COOLOFF',' 32' UNION ALL
SELECT '472817','39623','B','WI SAW-4',' 35' UNION ALL
SELECT '472818','39623','B','WI OD GRIND GRP',' 50' UNION ALL
SELECT '472819','39623','B','WI ID GRIND GRP',' 55' UNION ALL
SELECT '472820','39623','B','WI OD GRIND GRP',' 60' UNION ALL
SELECT '472821','39623','B','WI SAW-5',' 70' UNION ALL
SELECT '472822','39623','B','WI INSPECT',' 80' UNION ALL
SELECT '472823','39623','B','WI STAMP-1',' 90' UNION ALL
SELECT '472824','39623','B','WI REWORK',' 100' UNION ALL
SELECT '472825','39623','C','WI PRESSGR-OR-2',' 10' UNION ALL
SELECT '472826','39623','C','WIORANGEOP',' 20' UNION ALL
SELECT '472827','39623','C','WI OVEN-3',' 30' UNION ALL
SELECT '472828','39623','C','WI PART COOLOFF',' 32' UNION ALL
SELECT '472829','39623','C','WI SAW-4',' 35' UNION ALL
SELECT '472830','39623','C','WI OD GRIND GRP',' 50' UNION ALL
SELECT '472831','39623','C','WI ID GRIND GRP',' 55' UNION ALL
SELECT '472832','39623','C','WI OD GRIND GRP',' 60' UNION ALL
SELECT '472833','39623','C','WI SAW-5',' 70' UNION ALL
SELECT '472834','39623','C','WI INSPECT',' 80' UNION ALL
SELECT '472835','39623','C','WI STAMP-1',' 90' UNION ALL
SELECT '472836','39623','C','WI REWORK',' 100' UNION ALL
SELECT '472856','39628','1','WI SAW-8',' 20' UNION ALL
SELECT '472857','39628','1','WI SAND-4',' 30' UNION ALL
SELECT '472858','39628','1','WI SAW-7',' 35' UNION ALL
SELECT '472859','39628','1','WI SAW-3',' 40' UNION ALL
SELECT '472860','39628','1','WI STAMP-1',' 70' UNION ALL
SELECT '472861','39628','1','WI REWORK',' 80' UNION ALL
SELECT '472863','39629','1','WI PRESSGR-AG2',' 20' UNION ALL
SELECT '472864','39629','1','WIPRESSOP',' 25' UNION ALL
SELECT '472865','39629','1','WI OVEN-1',' 30' UNION ALL
SELECT '472866','39629','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472867','39629','1','WI SAND-1',' 40' UNION ALL
SELECT '472868','39629','1','WI INSPECT',' 45' UNION ALL
SELECT '472869','39629','1','WI STAMP-1',' 50' UNION ALL
SELECT '472870','39629','1','WI REWORK',' 60' UNION ALL
SELECT '472871','39630','1','WI CNCROUTE GRP',' 40' UNION ALL
SELECT '472872','39630','1','WI CNCROUTE GRP',' 48' UNION ALL
SELECT '472873','39630','1','WICNCROUTOP',' 49' UNION ALL
SELECT '472874','39630','1','WI SAND-2',' 50' UNION ALL
SELECT '472875','39630','1','WI STAMP-1',' 70' UNION ALL
SELECT '472876','39630','1','WI REWORK',' 80' UNION ALL
SELECT '472881','39631','1','WI PRESSGR-AG1',' 20' UNION ALL
SELECT '472882','39631','1','WIPRESSOP',' 25' UNION ALL
SELECT '472883','39631','1','WI OVEN-1',' 30' UNION ALL
SELECT '472884','39631','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472885','39631','1','WI SAND-1',' 40' UNION ALL
SELECT '472886','39631','1','WI INSPECT',' 45' UNION ALL
SELECT '472887','39631','1','WI STAMP-1',' 50' UNION ALL
SELECT '472888','39631','1','WI REWORK',' 60' UNION ALL
SELECT '472889','39632','1','WI PRESSGR-AG2',' 20' UNION ALL
SELECT '472890','39632','1','WIPRESSOP',' 25' UNION ALL
SELECT '472891','39632','1','WI OVEN-1',' 30' UNION ALL
SELECT '472892','39632','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472893','39632','1','WI SAND-1',' 40' UNION ALL
SELECT '472894','39632','1','WI INSPECT',' 45' UNION ALL
SELECT '472895','39632','1','WI STAMP-1',' 50' UNION ALL
SELECT '472896','39632','1','WI REWORK',' 60' UNION ALL
SELECT '472899','39633','1','WI SHEAR-2',' 25' UNION ALL
SELECT '472900','39633','1','WI SAND-4',' 30' UNION ALL
SELECT '472901','39633','1','WI STAMP-1',' 50' UNION ALL
SELECT '472902','39633','1','WI REWORK',' 60' UNION ALL
SELECT '472903','39634','1','WI SAW-7',' 30' UNION ALL
SELECT '472904','39634','1','WI SAND-4',' 40' UNION ALL
SELECT '472905','39634','1','WI STAMP-1',' 60' UNION ALL
SELECT '472906','39634','1','WI REWORK',' 70' UNION ALL
SELECT '472907','39635','1','WI PULL FR STK',' 30' UNION ALL
SELECT '472908','39635','1','WI SHIPPING STK',' 40' UNION ALL
SELECT '472909','39636','1','WI PRESSGR-GR2',' 10' UNION ALL
SELECT '472910','39636','1','WIPRESSOP',' 20' UNION ALL
SELECT '472911','39636','1','WI OVEN-2',' 30' UNION ALL
SELECT '472912','39636','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472913','39636','1','WI SAND-2',' 40' UNION ALL
SELECT '472914','39636','1','WI INSPECT',' 45' UNION ALL
SELECT '472915','39636','1','WI STAMP-1',' 50' UNION ALL
SELECT '472916','39636','1','WI REWORK',' 60' UNION ALL
SELECT '472917','39637','1','WI SAW-8',' 20' UNION ALL
SELECT '472918','39637','1','WI SAND-4',' 30' UNION ALL
SELECT '472919','39637','1','WI SAW-7',' 40' UNION ALL
SELECT '472920','39637','1','WI HANDWORK',' 70' UNION ALL
SELECT '472921','39637','1','WI STAMP-1',' 80' UNION ALL
SELECT '472922','39637','1','WI REWORK',' 90' UNION ALL
SELECT '472923','39638','1','WI SAND-2',' 50' UNION ALL
SELECT '472924','39638','1','WI STAMP-1',' 80' UNION ALL
SELECT '472925','39638','1','WI REWORK',' 90' UNION ALL
SELECT '472926','39639','1','WI SRL GRP',' 20' UNION ALL
SELECT '472927','39639','1','WI REWORK',' 70' UNION ALL
SELECT '472928','39640','1','WI SRL GRP',' 20' UNION ALL
SELECT '472929','39640','1','WI REWORK',' 70' UNION ALL
SELECT '472930','39641','1','WI SRL GRP',' 20' UNION ALL
SELECT '472931','39641','1','WI REWORK',' 70' UNION ALL
SELECT '472932','39642','1','WI PRESSGR-NHB1',' 25' UNION ALL
SELECT '472933','39642','1','WIPRESSOP',' 30' UNION ALL
SELECT '472934','39642','1','WI OVEN-5',' 50' UNION ALL
SELECT '472935','39642','1','WI PART COOLOFF',' 55' UNION ALL
SELECT '472936','39642','1','WI SAND-6',' 60' UNION ALL
SELECT '472937','39642','1','WI INSPECT',' 70' UNION ALL
SELECT '472938','39642','1','WI STAMP-1',' 90' UNION ALL
SELECT '472939','39642','1','WI REWORK',' 100' UNION ALL
SELECT '472940','39643','1','WI PRESSGR-CM9',' 10' UNION ALL
SELECT '472941','39643','1','WIPRESSOP',' 15' UNION ALL
SELECT '472942','39643','1','WI SAND-2',' 30' UNION ALL
SELECT '472943','39643','1','WI OVEN-2',' 40' UNION ALL
SELECT '472944','39643','1','WI PART COOLOFF',' 41' UNION ALL
SELECT '472945','39643','1','WI CNCROUTE GRP',' 48' UNION ALL
SELECT '472946','39643','1','WI CNCROUTE GRP',' 49' UNION ALL
SELECT '472947','39643','1','WI CNCROUTE GRP',' 50' UNION ALL
SELECT '472948','39643','1','WICNCROUTOP',' 51' UNION ALL
SELECT '472949','39643','1','WI SAND-2',' 60' UNION ALL
SELECT '472950','39643','1','WI SAND-1',' 70' UNION ALL
SELECT '472951','39643','1','WI INSPECT',' 79' UNION ALL
SELECT '472952','39643','1','WI STAMP-1',' 80' UNION ALL
SELECT '472953','39643','1','WI REWORK',' 90' UNION ALL
SELECT '472954','39644','1','WI MIX-1',' 10' UNION ALL
SELECT '472955','39645','1','WI MIX-1',' 10' UNION ALL
SELECT '472956','39646','1','WI PRESS-11',' 20' UNION ALL
SELECT '472957','39646','1','WIPRESSOP',' 25' UNION ALL
SELECT '472958','39646','1','WI OVEN-2',' 30' UNION ALL
SELECT '472959','39646','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472960','39646','1','WI SAND-2',' 40' UNION ALL
SELECT '472961','39646','1','WI CNCROUT-3',' 50' UNION ALL
SELECT '472962','39646','1','WICNCROUTOP',' 53' UNION ALL
SELECT '472963','39646','1','WI INSPECT',' 55' UNION ALL
SELECT '472964','39646','1','WI STAMP-1',' 60' UNION ALL
SELECT '472965','39646','1','WI REWORK',' 70' UNION ALL
SELECT '472966','39647','1','WI PRESSGR-GR2',' 20' UNION ALL
SELECT '472967','39647','1','WIPRESSOP',' 25' UNION ALL
SELECT '472968','39647','1','WI OVEN-2',' 30' UNION ALL
SELECT '472969','39647','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '472970','39647','1','WI SAND-2',' 40' UNION ALL
SELECT '472971','39647','1','WI CNCROUT-3',' 50' UNION ALL
SELECT '472972','39647','1','WICNCROUTOP',' 53' UNION ALL
SELECT '472973','39647','1','WI INSPECT',' 55' UNION ALL
SELECT '472974','39647','1','WI STAMP-1',' 60' UNION ALL
SELECT '472975','39647','1','WI REWORK',' 70' UNION ALL
SELECT '472976','39648','1','WI PRESSGR-CM10',' 20' UNION ALL
SELECT '472977','39648','1','WIPRESSOP',' 25' UNION ALL
SELECT '472978','39648','1','WI OVEN-2',' 30' UNION ALL
SELECT '472979','39648','1','WI PART COOLOFF',' 31' UNION ALL
SELECT '472980','39648','1','WI SAND-1',' 40' UNION ALL
SELECT '472981','39648','1','WI INSPECT',' 49' UNION ALL
SELECT '472982','39648','1','WI STAMP-1',' 50' UNION ALL
SELECT '472983','39648','1','WI SHIPPING',' 55' UNION ALL
SELECT '472984','39648','1','WI REWORK',' 60' UNION ALL
SELECT '472986','39648','1','WI SAND-2',' 27' UNION ALL
SELECT '472988','39649','1','WI SRL GRP',' 20' UNION ALL
SELECT '472989','39649','1','WI REWORK',' 30' UNION ALL
SELECT '473087','39650','1','WI SRL GRP',' 20' UNION ALL
SELECT '473088','39650','1','WI REWORK',' 70' UNION ALL
SELECT '473089','39651','1','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473090','39651','1','WIORANGEOP',' 20' UNION ALL
SELECT '473091','39651','1','WI OVEN-3',' 30' UNION ALL
SELECT '473092','39651','1','WI PART COOLOFF',' 33' UNION ALL
SELECT '473093','39651','1','WI SAW-4',' 35' UNION ALL
SELECT '473094','39651','1','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473095','39651','1','WI ID GRIND GRP',' 55' UNION ALL
SELECT '473096','39651','1','WI OD GRIND GRP',' 60' UNION ALL
SELECT '473097','39651','1','WI SAW-3',' 70' UNION ALL
SELECT '473098','39651','1','WI INSPECT',' 80' UNION ALL
SELECT '473099','39651','1','WI STAMP-1',' 90' UNION ALL
SELECT '473100','39651','1','WI REWORK',' 100' UNION ALL
SELECT '473109','39653','1','WI PRESS-11',' 10' UNION ALL
SELECT '473110','39653','1','WIPRESSOP',' 20' UNION ALL
SELECT '473111','39653','1','WI OVEN-2',' 30' UNION ALL
SELECT '473112','39653','1','WI PART COOLOFF',' 35' UNION ALL
SELECT '473113','39653','1','WI SAND-2',' 40' UNION ALL
SELECT '473114','39653','1','WI CNCROUT-3',' 45' UNION ALL
SELECT '473115','39653','1','WICNCROUTOP',' 47' UNION ALL
SELECT '473116','39653','1','WI INSPECT',' 48' UNION ALL
SELECT '473117','39653','1','WI STAMP-1',' 50' UNION ALL
SELECT '473118','39653','1','WI REWORK',' 60' UNION ALL
SELECT '473119','39654','1','WI PRESSGR-CM10',' 20' UNION ALL
SELECT '473120','39654','1','WIPRESSOP',' 30' UNION ALL
SELECT '473121','39654','1','WI SAND-2',' 40' UNION ALL
SELECT '473122','39654','1','WI OVEN-2',' 50' UNION ALL
SELECT '473123','39654','1','WI PART COOLOFF',' 51' UNION ALL
SELECT '473124','39654','1','WI SAND-2',' 60' UNION ALL
SELECT '473125','39654','1','WI CNCMILL GRP',' 70' UNION ALL
SELECT '473126','39654','1','WICNCMILLOP',' 75' UNION ALL
SELECT '473127','39654','1','WI INSPECT',' 78' UNION ALL
SELECT '473128','39654','1','WI STAMP-1',' 80' UNION ALL
SELECT '473129','39654','1','WI REWORK',' 90' UNION ALL
SELECT '473130','39655','1','WI SAW-7',' 30' UNION ALL
SELECT '473131','39655','1','WI SAND-4',' 35' UNION ALL
SELECT '473132','39655','1','WI OVEN-6',' 40' UNION ALL
SELECT '473133','39655','1','WI CNCROUT-3',' 46' UNION ALL
SELECT '473134','39655','1','WI CNCROUT-3',' 48' UNION ALL
SELECT '473135','39655','1','WI CNCROUT-3',' 50' UNION ALL
SELECT '473136','39655','1','WI SAND-2',' 60' UNION ALL
SELECT '473137','39655','1','WI SAND-1',' 80' UNION ALL
SELECT '473138','39655','1','WI STAMP-1',' 100' UNION ALL
SELECT '473139','39655','1','WI REWORK',' 110' UNION ALL
SELECT '473140','39656','1','WI SAW-7',' 30' UNION ALL
SELECT '473141','39656','1','WI OVEN-6',' 50' UNION ALL
SELECT '473142','39656','1','WI OVEN-6',' 55' UNION ALL
SELECT '473143','39656','1','WI CNCROUTE GRP',' 58' UNION ALL
SELECT '473144','39656','1','WI CNCROUTE GRP',' 59' UNION ALL
SELECT '473145','39656','1','WI CNCROUTE GRP',' 60' UNION ALL
SELECT '473146','39656','1','WI SAND-2',' 70' UNION ALL
SELECT '473147','39656','1','WI SAND-4',' 80' UNION ALL
SELECT '473148','39656','1','WI STAMP-1',' 100' UNION ALL
SELECT '473149','39656','1','WI REWORK',' 110' UNION ALL
SELECT '473150','39657','1','WI MIX-1',' 10' UNION ALL
SELECT '473151','39658','1','WI PRESSGR-OR-2',' 10' UNION ALL
SELECT '473152','39658','1','WIORANGEOP',' 15' UNION ALL
SELECT '473153','39658','1','WI OVEN-3',' 20' UNION ALL
SELECT '473154','39658','1','WI PART COOLOFF',' 25' UNION ALL
SELECT '473155','39658','1','WI SAW-4',' 30' UNION ALL
SELECT '473156','39658','1','WI OD GRIND GRP',' 40' UNION ALL
SELECT '473157','39658','1','WI ID GRIND GRP',' 50' UNION ALL
SELECT '473158','39658','1','WI OD GRIND GRP',' 60' UNION ALL
SELECT '473159','39658','1','WI SAW-3',' 70' UNION ALL
SELECT '473160','39658','1','WI DRILL GROUP',' 80' UNION ALL
SELECT '473161','39658','1','WI DRILL GROUP',' 85' UNION ALL
SELECT '473162','39658','1','WI INSPECT',' 87' UNION ALL
SELECT '473163','39658','1','WI STAMP-1',' 90' UNION ALL
SELECT '473164','39658','1','WI REWORK',' 100' UNION ALL
SELECT '473177','39659','A','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473178','39659','A','WIORANGEOP',' 20' UNION ALL
SELECT '473179','39659','A','WI OVEN-3',' 30' UNION ALL
SELECT '473180','39659','A','WI PART COOLOFF',' 35' UNION ALL
SELECT '473181','39659','A','WI SAW-4',' 40' UNION ALL
SELECT '473182','39659','A','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473183','39659','A','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473184','39659','A','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473185','39659','A','WI SAW-3',' 90' UNION ALL
SELECT '473186','39659','A','WI INSPECT',' 95' UNION ALL
SELECT '473187','39659','A','WI STAMP-1',' 100' UNION ALL
SELECT '473188','39659','A','WI REWORK',' 110' UNION ALL
SELECT '473189','39659','B','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473190','39659','B','WIORANGEOP',' 20' UNION ALL
SELECT '473191','39659','B','WI OVEN-3',' 30' UNION ALL
SELECT '473192','39659','B','WI PART COOLOFF',' 35' UNION ALL
SELECT '473193','39659','B','WI SAW-4',' 40' UNION ALL
SELECT '473194','39659','B','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473195','39659','B','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473196','39659','B','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473197','39659','B','WI SAW-3',' 90' UNION ALL
SELECT '473198','39659','B','WI INSPECT',' 95' UNION ALL
SELECT '473199','39659','B','WI STAMP-1',' 100' UNION ALL
SELECT '473200','39659','B','WI REWORK',' 110' UNION ALL
SELECT '473201','39659','C','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473202','39659','C','WIORANGEOP',' 20' UNION ALL
SELECT '473203','39659','C','WI OVEN-3',' 30' UNION ALL
SELECT '473204','39659','C','WI PART COOLOFF',' 35' UNION ALL
SELECT '473205','39659','C','WI SAW-4',' 40' UNION ALL
SELECT '473206','39659','C','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473207','39659','C','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473208','39659','C','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473209','39659','C','WI SAW-3',' 90' UNION ALL
SELECT '473210','39659','C','WI INSPECT',' 95' UNION ALL
SELECT '473211','39659','C','WI STAMP-1',' 100' UNION ALL
SELECT '473212','39659','C','WI REWORK',' 110' UNION ALL
SELECT '473213','39659','D','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473214','39659','D','WIORANGEOP',' 20' UNION ALL
SELECT '473215','39659','D','WI OVEN-3',' 30' UNION ALL
SELECT '473216','39659','D','WI PART COOLOFF',' 35' UNION ALL
SELECT '473217','39659','D','WI SAW-4',' 40' UNION ALL
SELECT '473218','39659','D','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473219','39659','D','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473220','39659','D','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473221','39659','D','WI SAW-3',' 90' UNION ALL
SELECT '473222','39659','D','WI INSPECT',' 95' UNION ALL
SELECT '473223','39659','D','WI STAMP-1',' 100' UNION ALL
SELECT '473224','39659','D','WI REWORK',' 110' UNION ALL
SELECT '473225','39659','E','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473226','39659','E','WIORANGEOP',' 20' UNION ALL
SELECT '473227','39659','E','WI OVEN-3',' 30' UNION ALL
SELECT '473228','39659','E','WI PART COOLOFF',' 35' UNION ALL
SELECT '473229','39659','E','WI SAW-4',' 40' UNION ALL
SELECT '473230','39659','E','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473231','39659','E','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473232','39659','E','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473233','39659','E','WI SAW-3',' 90' UNION ALL
SELECT '473234','39659','E','WI INSPECT',' 95' UNION ALL
SELECT '473235','39659','E','WI STAMP-1',' 100' UNION ALL
SELECT '473236','39659','E','WI REWORK',' 110' UNION ALL
SELECT '473237','39659','F','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473238','39659','F','WIORANGEOP',' 20' UNION ALL
SELECT '473239','39659','F','WI OVEN-3',' 30' UNION ALL
SELECT '473240','39659','F','WI PART COOLOFF',' 35' UNION ALL
SELECT '473241','39659','F','WI SAW-4',' 40' UNION ALL
SELECT '473242','39659','F','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473243','39659','F','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473244','39659','F','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473245','39659','F','WI SAW-3',' 90' UNION ALL
SELECT '473246','39659','F','WI INSPECT',' 95' UNION ALL
SELECT '473247','39659','F','WI STAMP-1',' 100' UNION ALL
SELECT '473248','39659','F','WI REWORK',' 110' UNION ALL
SELECT '473249','39659','G','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473250','39659','G','WIORANGEOP',' 20' UNION ALL
SELECT '473251','39659','G','WI OVEN-3',' 30' UNION ALL
SELECT '473252','39659','G','WI PART COOLOFF',' 35' UNION ALL
SELECT '473253','39659','G','WI SAW-4',' 40' UNION ALL
SELECT '473254','39659','G','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473255','39659','G','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473256','39659','G','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473257','39659','G','WI SAW-3',' 90' UNION ALL
SELECT '473258','39659','G','WI INSPECT',' 95' UNION ALL
SELECT '473259','39659','G','WI STAMP-1',' 100' UNION ALL
SELECT '473260','39659','G','WI REWORK',' 110' UNION ALL
SELECT '473261','39659','H','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473262','39659','H','WIORANGEOP',' 20' UNION ALL
SELECT '473263','39659','H','WI OVEN-3',' 30' UNION ALL
SELECT '473264','39659','H','WI PART COOLOFF',' 35' UNION ALL
SELECT '473265','39659','H','WI SAW-4',' 40' UNION ALL
SELECT '473266','39659','H','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473267','39659','H','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473268','39659','H','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473269','39659','H','WI SAW-3',' 90' UNION ALL
SELECT '473270','39659','H','WI INSPECT',' 95' UNION ALL
SELECT '473271','39659','H','WI STAMP-1',' 100' UNION ALL
SELECT '473272','39659','H','WI REWORK',' 110' UNION ALL
SELECT '473283','39660','A','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473284','39660','A','WIORANGEOP',' 20' UNION ALL
SELECT '473285','39660','A','WI OVEN-3',' 30' UNION ALL
SELECT '473286','39660','A','WI PART COOLOFF',' 40' UNION ALL
SELECT '473287','39660','A','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473288','39660','A','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473289','39660','A','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473290','39660','A','WI INSPECT',' 90' UNION ALL
SELECT '473291','39660','A','WI STAMP-1',' 100' UNION ALL
SELECT '473292','39660','A','WI REWORK',' 110' UNION ALL
SELECT '473293','39660','B','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473294','39660','B','WIORANGEOP',' 20' UNION ALL
SELECT '473295','39660','B','WI OVEN-3',' 30' UNION ALL
SELECT '473296','39660','B','WI PART COOLOFF',' 40' UNION ALL
SELECT '473297','39660','B','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473298','39660','B','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473299','39660','B','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473300','39660','B','WI INSPECT',' 90' UNION ALL
SELECT '473301','39660','B','WI STAMP-1',' 100' UNION ALL
SELECT '473302','39660','B','WI REWORK',' 110' UNION ALL
SELECT '473303','39660','C','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473304','39660','C','WIORANGEOP',' 20' UNION ALL
SELECT '473305','39660','C','WI OVEN-3',' 30' UNION ALL
SELECT '473306','39660','C','WI PART COOLOFF',' 40' UNION ALL
SELECT '473307','39660','C','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473308','39660','C','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473309','39660','C','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473310','39660','C','WI INSPECT',' 90' UNION ALL
SELECT '473311','39660','C','WI STAMP-1',' 100' UNION ALL
SELECT '473312','39660','C','WI REWORK',' 110' UNION ALL
SELECT '473313','39660','D','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473314','39660','D','WIORANGEOP',' 20' UNION ALL
SELECT '473315','39660','D','WI OVEN-3',' 30' UNION ALL
SELECT '473316','39660','D','WI PART COOLOFF',' 40' UNION ALL
SELECT '473317','39660','D','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473318','39660','D','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473319','39660','D','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473320','39660','D','WI INSPECT',' 90' UNION ALL
SELECT '473321','39660','D','WI STAMP-1',' 100' UNION ALL
SELECT '473322','39660','D','WI REWORK',' 110' UNION ALL
SELECT '473323','39660','E','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473324','39660','E','WIORANGEOP',' 20' UNION ALL
SELECT '473325','39660','E','WI OVEN-3',' 30' UNION ALL
SELECT '473326','39660','E','WI PART COOLOFF',' 40' UNION ALL
SELECT '473327','39660','E','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473328','39660','E','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473329','39660','E','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473330','39660','E','WI INSPECT',' 90' UNION ALL
SELECT '473331','39660','E','WI STAMP-1',' 100' UNION ALL
SELECT '473332','39660','E','WI REWORK',' 110' UNION ALL
SELECT '473333','39660','F','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473334','39660','F','WIORANGEOP',' 20' UNION ALL
SELECT '473335','39660','F','WI OVEN-3',' 30' UNION ALL
SELECT '473336','39660','F','WI PART COOLOFF',' 40' UNION ALL
SELECT '473337','39660','F','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473338','39660','F','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473339','39660','F','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473340','39660','F','WI INSPECT',' 90' UNION ALL
SELECT '473341','39660','F','WI STAMP-1',' 100' UNION ALL
SELECT '473342','39660','F','WI REWORK',' 110' UNION ALL
SELECT '473343','39660','G','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473344','39660','G','WIORANGEOP',' 20' UNION ALL
SELECT '473345','39660','G','WI OVEN-3',' 30' UNION ALL
SELECT '473346','39660','G','WI PART COOLOFF',' 40' UNION ALL
SELECT '473347','39660','G','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473348','39660','G','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473349','39660','G','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473350','39660','G','WI INSPECT',' 90' UNION ALL
SELECT '473351','39660','G','WI STAMP-1',' 100' UNION ALL
SELECT '473352','39660','G','WI REWORK',' 110' UNION ALL
SELECT '473353','39660','H','WI PRESSGR-OR-3',' 10' UNION ALL
SELECT '473354','39660','H','WIORANGEOP',' 20' UNION ALL
SELECT '473355','39660','H','WI OVEN-3',' 30' UNION ALL
SELECT '473356','39660','H','WI PART COOLOFF',' 40' UNION ALL
SELECT '473357','39660','H','WI OD GRIND GRP',' 50' UNION ALL
SELECT '473358','39660','H','WI ID GRIND GRP',' 70' UNION ALL
SELECT '473359','39660','H','WI OD GRIND GRP',' 80' UNION ALL
SELECT '473360','39660','H','WI INSPECT',' 90' UNION ALL
SELECT '473361','39660','H','WI STAMP-1',' 100' UNION ALL
SELECT '473362','39660','H','WI REWORK',' 110' UNION ALL
SELECT '476727','39627','A','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '476728','39627','A','WIPRESSOP',' 25' UNION ALL
SELECT '476729','39627','A','WI SAND-2',' 26' UNION ALL
SELECT '476730','39627','A','WI OVEN-2',' 30' UNION ALL
SELECT '476731','39627','A','WI PART COOLOFF',' 32' UNION ALL
SELECT '476732','39627','A','WI SAND-2',' 33' UNION ALL
SELECT '476733','39627','A','WI INSPECT',' 40' UNION ALL
SELECT '476734','39627','A','WI STAMP-1',' 50' UNION ALL
SELECT '476735','39627','A','WI REWORK',' 60' UNION ALL
SELECT '478812','39627','G','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '478813','39627','G','WIPRESSOP',' 25' UNION ALL
SELECT '478814','39627','G','WI SAND-2',' 26' UNION ALL
SELECT '478815','39627','G','WI OVEN-2',' 30' UNION ALL
SELECT '478816','39627','G','WI PART COOLOFF',' 32' UNION ALL
SELECT '478817','39627','G','WI SAND-2',' 33' UNION ALL
SELECT '478818','39627','G','WI INSPECT',' 40' UNION ALL
SELECT '478819','39627','G','WI STAMP-1',' 50' UNION ALL
SELECT '478820','39627','G','WI REWORK',' 60' UNION ALL
SELECT '478821','39627','H','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '478822','39627','H','WIPRESSOP',' 25' UNION ALL
SELECT '478823','39627','H','WI SAND-2',' 26' UNION ALL
SELECT '478824','39627','H','WI OVEN-2',' 30' UNION ALL
SELECT '478825','39627','H','WI PART COOLOFF',' 32' UNION ALL
SELECT '478826','39627','H','WI SAND-2',' 33' UNION ALL
SELECT '478827','39627','H','WI INSPECT',' 40' UNION ALL
SELECT '478828','39627','H','WI STAMP-1',' 50' UNION ALL
SELECT '478829','39627','H','WI REWORK',' 60' UNION ALL
SELECT '478830','39627','I','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '478831','39627','I','WIPRESSOP',' 25' UNION ALL
SELECT '478832','39627','I','WI SAND-2',' 26' UNION ALL
SELECT '478833','39627','I','WI OVEN-2',' 30' UNION ALL
SELECT '478834','39627','I','WI PART COOLOFF',' 32' UNION ALL
SELECT '478835','39627','I','WI SAND-2',' 33' UNION ALL
SELECT '478836','39627','I','WI INSPECT',' 40' UNION ALL
SELECT '478837','39627','I','WI STAMP-1',' 50' UNION ALL
SELECT '478838','39627','I','WI REWORK',' 60' UNION ALL
SELECT '478839','39627','J','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '478840','39627','J','WIPRESSOP',' 25' UNION ALL
SELECT '478841','39627','J','WI SAND-2',' 26' UNION ALL
SELECT '478842','39627','J','WI OVEN-2',' 30' UNION ALL
SELECT '478843','39627','J','WI PART COOLOFF',' 32' UNION ALL
SELECT '478844','39627','J','WI SAND-2',' 33' UNION ALL
SELECT '478845','39627','J','WI INSPECT',' 40' UNION ALL
SELECT '478846','39627','J','WI STAMP-1',' 50' UNION ALL
SELECT '478847','39627','J','WI REWORK',' 60' UNION ALL
SELECT '478858','39626','A','WI PRESSGR-GR2',' 20' UNION ALL
SELECT '478859','39626','A','WIPRESSOP',' 25' UNION ALL
SELECT '478860','39626','A','WI SAND-2',' 28' UNION ALL
SELECT '478861','39626','A','WI OVEN-2',' 30' UNION ALL
SELECT '478862','39626','A','WI PART COOLOFF',' 35' UNION ALL
SELECT '478863','39626','A','WI SAND-2',' 40' UNION ALL
SELECT '478864','39626','A','WI SAW-2',' 50' UNION ALL
SELECT '478865','39626','A','WI INSPECT',' 55' UNION ALL
SELECT '478866','39626','A','WI STAMP-1',' 60' UNION ALL
SELECT '478867','39626','A','WI REWORK',' 70' UNION ALL
SELECT '478868','39626','B','WI PRESSGR-GR2',' 20' UNION ALL
SELECT '478869','39626','B','WIPRESSOP',' 25' UNION ALL
SELECT '478870','39626','B','WI SAND-2',' 28' UNION ALL
SELECT '478871','39626','B','WI OVEN-2',' 30' UNION ALL
SELECT '478872','39626','B','WI PART COOLOFF',' 35' UNION ALL
SELECT '478873','39626','B','WI SAND-2',' 40' UNION ALL
SELECT '478874','39626','B','WI SAW-2',' 50' UNION ALL
SELECT '478875','39626','B','WI INSPECT',' 55' UNION ALL
SELECT '478876','39626','B','WI STAMP-1',' 60' UNION ALL
SELECT '478877','39626','B','WI REWORK',' 70' UNION ALL
SELECT '478893','39626','C','WI PRESSGR-GR2',' 20' UNION ALL
SELECT '478894','39626','C','WIPRESSOP',' 25' UNION ALL
SELECT '478895','39626','C','WI SAND-2',' 28' UNION ALL
SELECT '478896','39626','C','WI OVEN-2',' 30' UNION ALL
SELECT '478897','39626','C','WI PART COOLOFF',' 35' UNION ALL
SELECT '478898','39626','C','WI SAND-2',' 40' UNION ALL
SELECT '478899','39626','C','WI SAW-2',' 50' UNION ALL
SELECT '478900','39626','C','WI INSPECT',' 55' UNION ALL
SELECT '478901','39626','C','WI STAMP-1',' 60' UNION ALL
SELECT '478902','39626','C','WI REWORK',' 70' UNION ALL
SELECT '480564','39627','B','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '480565','39627','B','WIPRESSOP',' 25' UNION ALL
SELECT '480566','39627','B','WI SAND-2',' 26' UNION ALL
SELECT '480567','39627','B','WI OVEN-2',' 30' UNION ALL
SELECT '480568','39627','B','WI PART COOLOFF',' 32' UNION ALL
SELECT '480569','39627','B','WI SAND-2',' 33' UNION ALL
SELECT '480570','39627','B','WI INSPECT',' 40' UNION ALL
SELECT '480571','39627','B','WI STAMP-1',' 50' UNION ALL
SELECT '480572','39627','B','WI REWORK',' 60' UNION ALL
SELECT '480573','39627','C','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '480574','39627','C','WIPRESSOP',' 25' UNION ALL
SELECT '480575','39627','C','WI SAND-2',' 26' UNION ALL
SELECT '480576','39627','C','WI OVEN-2',' 30' UNION ALL
SELECT '480577','39627','C','WI PART COOLOFF',' 32' UNION ALL
SELECT '480578','39627','C','WI SAND-2',' 33' UNION ALL
SELECT '480579','39627','C','WI INSPECT',' 40' UNION ALL
SELECT '480580','39627','C','WI STAMP-1',' 50' UNION ALL
SELECT '480581','39627','C','WI REWORK',' 60' UNION ALL
SELECT '480590','39627','D','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '480591','39627','D','WIPRESSOP',' 25' UNION ALL
SELECT '480592','39627','D','WI SAND-2',' 26' UNION ALL
SELECT '480593','39627','D','WI OVEN-2',' 30' UNION ALL
SELECT '480594','39627','D','WI PART COOLOFF',' 32' UNION ALL
SELECT '480595','39627','D','WI SAND-2',' 33' UNION ALL
SELECT '480596','39627','D','WI INSPECT',' 40' UNION ALL
SELECT '480597','39627','D','WI STAMP-1',' 50' UNION ALL
SELECT '480598','39627','D','WI REWORK',' 60' UNION ALL
SELECT '480599','39627','E','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '480600','39627','E','WIPRESSOP',' 25' UNION ALL
SELECT '480601','39627','E','WI SAND-2',' 26' UNION ALL
SELECT '480602','39627','E','WI OVEN-2',' 30' UNION ALL
SELECT '480603','39627','E','WI PART COOLOFF',' 32' UNION ALL
SELECT '480604','39627','E','WI SAND-2',' 33' UNION ALL
SELECT '480605','39627','E','WI INSPECT',' 40' UNION ALL
SELECT '480606','39627','E','WI STAMP-1',' 50' UNION ALL
SELECT '480607','39627','E','WI REWORK',' 60' UNION ALL
SELECT '480608','39627','F','WI PRESSGR-CM1',' 20' UNION ALL
SELECT '480609','39627','F','WIPRESSOP',' 25' UNION ALL
SELECT '480610','39627','F','WI SAND-2',' 26' UNION ALL
SELECT '480611','39627','F','WI OVEN-2',' 30' UNION ALL
SELECT '480612','39627','F','WI PART COOLOFF',' 32' UNION ALL
SELECT '480613','39627','F','WI SAND-2',' 33' UNION ALL
SELECT '480614','39627','F','WI INSPECT',' 40' UNION ALL
SELECT '480615','39627','F','WI STAMP-1',' 50' UNION ALL
SELECT '480616','39627','F','WI REWORK',' 60' UNION ALL
SELECT '488117','39652','A','WI PRESSGR-AG2',' 20' UNION ALL
SELECT '488118','39652','A','WIPRESSOP',' 25' UNION ALL
SELECT '488119','39652','A','WI OVEN-1',' 30' UNION ALL
SELECT '488120','39652','A','WI PART COOLOFF',' 35' UNION ALL
SELECT '488121','39652','A','WI SAND-1',' 40' UNION ALL
SELECT '488122','39652','A','WI INSPECT',' 45' UNION ALL
SELECT '488123','39652','A','WI STAMP-1',' 50' UNION ALL
SELECT '488124','39652','A','WI REWORK',' 60' UNION ALL
SELECT '488125','39652','B','WI PRESSGR-AG2',' 20' UNION ALL
SELECT '488126','39652','B','WIPRESSOP',' 25' UNION ALL
SELECT '488127','39652','B','WI OVEN-1',' 30' UNION ALL
SELECT '488128','39652','B','WI PART COOLOFF',' 35' UNION ALL
SELECT '488129','39652','B','WI SAND-1',' 40' UNION ALL
SELECT '488130','39652','B','WI INSPECT',' 45' UNION ALL
SELECT '488131','39652','B','WI STAMP-1',' 50' UNION ALL
SELECT '488132','39652','B','WI REWORK',' 60' UNION ALL
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 '
Lowell
May 20, 2014 at 11:14 am
Here's an example of what we're hoping to get. You want the SQL to match YOUR data and YOUR database objects.
CREATE TABLE #mytable
(
ROWID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
WORKORDER_BASE_ID VARCHAR(10),
WORKORDER_LOT_ID VARCHAR(10),
RESOURCE_ID VARCHAR(30),
SEQUENCE_NO VARCHAR(10)
)
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'
Notice how the table defintion (the stuff after "CREATE TABLE") matches the inserts that follow. Also, notice I removed the LAST OCCURRENCE of "UNION ALL".
Just posting in case it helps.
May 20, 2014 at 11:50 am
Below is the entire query. The statement provided by Lowell provides the desired results, thank you. How can I best utilize this data to create a view or something that I can retrieve all of the records (there are thousands) so that they may be used in a Crystal Report?
IF OBJECT_ID('tempdb..#mytable') IS NOT NULL
DROP TABLE #mytable
CREATE TABLE #mytable
(
ROWID INT NOT NULL PRIMARY KEY IDENTITY(1, 1),
WORKORDER_BASE_ID VARCHAR(30),
WORKORDER_LOT_ID VARCHAR(3),
RESOURCE_ID VARCHAR(15),
SEQUENCE_NO INT,
RUN DECIMAL(8,3)
);
SET IDENTITY_INSERT #mytable ON
INSERT INTO #mytable
(ROWID, WORKORDER_BASE_ID, WORKORDER_LOT_ID, RESOURCE_ID, SEQUENCE_NO, RUN)
SELECT '612633','48398','1','WI INSPECT','5','0.00000000' UNION ALL
SELECT '612634','48398','1','WI STAMP-1','10','0.00000000' UNION ALL
SELECT '612635','48398','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612636','48398','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612637','48398','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612638','48398','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612639','48398','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612640','48398','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612641','48398','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612642','48398','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612643','48398','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612644','48398','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612645','48398','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612646','48398','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612647','48398','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612648','48398','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612649','48398','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612650','48398','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612651','48398','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612652','48398','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612653','48398','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612654','48398','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612655','48398','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612656','48398','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612657','48398','1','WI REWORK','20','0.00000000' UNION ALL
SELECT '612658','48399','1','WI INSPECT','5','0.00000000' UNION ALL
SELECT '612659','48399','1','WI STAMP-1','10','0.00000000' UNION ALL
SELECT '612660','48399','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612661','48399','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612662','48399','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612663','48399','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612664','48399','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612665','48399','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612666','48399','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612667','48399','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612668','48399','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612669','48399','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612670','48399','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612671','48399','1','WI PRESSGR-OR-1','10','1.00000000' UNION ALL
SELECT '612672','48399','1','WIORANGEOP','15','0.08330000' UNION ALL
SELECT '612673','48399','1','WI OVEN-3','20','0.00000000' UNION ALL
SELECT '612674','48399','1','WI PART COOLOFF','25','0.00000000' UNION ALL
SELECT '612675','48399','1','WI SAW-4','30','30.00000000' UNION ALL
SELECT '612676','48399','1','WI OD GRIND GRP','40','60.00000000' UNION ALL
SELECT '612677','48399','1','WI ID GRIND GRP','50','60.00000000' UNION ALL
SELECT '612678','48399','1','WI OD GRIND GRP','60','30.00000000' UNION ALL
SELECT '612679','48399','1','WI SAW-3','70','120.00000000' UNION ALL
SELECT '612680','48399','1','WI DRILL GROUP','80','60.00000000' UNION ALL
SELECT '612681','48399','1','WI DRILL GROUP','90','60.00000000' UNION ALL
SELECT '612682','48399','1','WI REWORK','20','0.00000000'
SET IDENTITY_INSERT #mytable OFF
SELECT * FROM #mytable T1 LEFT OUTER JOIN #mytable T2 ON T1.[ROWID] = T2.[ROWID] -1
May 20, 2014 at 11:56 am
aberndt (5/20/2014)
Below is the entire query. The statement provided by Lowell provides the desired results, thank you. How can I best utilize this data to create a view or something that I can retrieve all of the records (there are thousands) so that they may be used in a Crystal Report?SELECT * FROM #mytable T1 LEFT OUTER JOIN #mytable T2 ON T1.[ROWID] = T2.[ROWID] -1
Do you want the view to return the results like the above query? If so, you can use that as the body of your view, but you would use your actual tables here instead of the temp tables. You also should not use select *, instead you should explicitly name the columns you want in your view.
http://msdn.microsoft.com/en-us/library/ms187956.aspx
create view MyView as
SELECT * FROM #mytable T1 LEFT OUTER JOIN #mytable T2 ON T1.[ROWID] = T2.[ROWID] -1
_______________________________________________________________
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 12:01 pm
I will work with this a bit and see what I can come up with. I have to leave for an off site meeting. Thank you for your help.
May 20, 2014 at 2:18 pm
Thank you all for your help. Below is the final query that generated my view with the data I wanted to retrieve:
SELECT T1.ROWID, T1.WORKORDER_TYPE, T1.WORKORDER_BASE_ID, T1.WORKORDER_LOT_ID, T1.WORKORDER_SPLIT_ID, T1.WORKORDER_SUB_ID,
T1.SEQUENCE_NO, T1.RESOURCE_ID, T1.RUN, T2.RUN AS PRESS_RUN
FROM dbo.OPERATION AS T1 LEFT OUTER JOIN
dbo.OPERATION AS T2 ON T1.ROWID = T2.ROWID + 1
Unfortunately because of the way the some of the work orders were created, the rows are not necessarily sequential as I was led to believe. Is there anyway to select a previous Sequence number? There is no rhyme or reason as to how the operations are numbered, just that the Press Run number I am trying to obtain comes from the operation immediately preceding the one I am working with. Some times there will be a difference of 1 between the sequence nos, sometimes there will be a difference of 10.
May 20, 2014 at 2:28 pm
aberndt (5/20/2014)
Thank you all for your help. Below is the final query that generated my view with the data I wanted to retrieve:SELECT T1.ROWID, T1.WORKORDER_TYPE, T1.WORKORDER_BASE_ID, T1.WORKORDER_LOT_ID, T1.WORKORDER_SPLIT_ID, T1.WORKORDER_SUB_ID,
T1.SEQUENCE_NO, T1.RESOURCE_ID, T1.RUN, T2.RUN AS PRESS_RUN
FROM dbo.OPERATION AS T1 LEFT OUTER JOIN
dbo.OPERATION AS T2 ON T1.ROWID = T2.ROWID + 1
Unfortunately because of the way the some of the work orders were created, the rows are not necessarily sequential as I was led to believe. Is there anyway to select a previous Sequence number? There is no rhyme or reason as to how the operations are numbered, just that the Press Run number I am trying to obtain comes from the operation immediately preceding the one I am working with. Some times there will be a difference of 1 between the sequence nos, sometimes there will be a difference of 10.
Something like this might help. Here I am using ROW_NUMBER to generate sequential numbers. The same query will work we just select from the cte now instead of the base table.
with Operations as
(
SELECT ROW_NUMBER() OVER (ORDER BY O.ROWID) as ROWID,
O.WORKORDER_TYPE,
O.WORKORDER_BASE_ID,
O.WORKORDER_LOT_ID,
O.WORKORDER_SPLIT_ID,
O.WORKORDER_SUB_ID,
O.SEQUENCE_NO,
O.RESOURCE_ID,
O.RUN
FROM dbo.OPERATION AS O
)
SELECT T1.ROWID,
T1.WORKORDER_TYPE,
T1.WORKORDER_BASE_ID,
T1.WORKORDER_LOT_ID,
T1.WORKORDER_SPLIT_ID,
T1.WORKORDER_SUB_ID,
T1.SEQUENCE_NO,
T1.RESOURCE_ID,
T1.RUN,
T2.RUN AS PRESS_RUN
FROM Operations AS T1
LEFT OUTER JOIN Operations AS T2 ON T1.ROWID = T2.ROWID + 1
_______________________________________________________________
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 2:39 pm
Very interesting...let me do some testing and let you know (probably tomorrow). I think this might work!
May 21, 2014 at 7:02 am
Sean - This is great! Can I change the order of the data before the rowid's are assigned? I'd like to sort by WORKORDER_BASE_ID, then by WORKORDER_LOT_ID, then by WORKORDER_SUB_ID, then by SEQUENCE_NO. Is that possible? Please let me know.
May 21, 2014 at 7:27 am
aberndt (5/21/2014)
Sean - This is great! Can I change the order of the data before the rowid's are assigned? I'd like to sort by WORKORDER_BASE_ID, then by WORKORDER_LOT_ID, then by WORKORDER_SUB_ID, then by SEQUENCE_NO. Is that possible? Please let me know.
Sure you can do that.
ROW_NUMBER() OVER (ORDER BY WORKORDER_BASE_ID, WORKORDER_LOT_ID, WORKORDER_SUB_ID, SEQUENCE_NO) as RowNum
You should probably hit BOL and lookup ROW_NUMBER so you understand what is going on.
_______________________________________________________________
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 21, 2014 at 9:03 am
This works great, thank you so much. I can create a view to get the information that I need into my report but is there a more efficient way? The report takes a long time to run but I understand what I am asking the server to do with the data so I can live with the time if there is no other way to do this.
May 21, 2014 at 9:14 am
aberndt (5/21/2014)
This works great, thank you so much. I can create a view to get the information that I need into my report but is there a more efficient way? The report takes a long time to run but I understand what I am asking the server to do with the data so I can live with the time if there is no other way to do this.
We have managed to get the correct data so far, that is good. Now we need to get it faster.
Again, we can help but you need to provide some other types of details. The actual execution plan would be a huge help. Additionally the table and index definitions of your real tables.
_______________________________________________________________
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 21, 2014 at 10:17 am
I'm going to make some adjustments to this report on my end first. Now that I am looking at it, there are some parameters and selections that don't need to be in there. It was originally based on another report that required more criteria. I will let you know when I am done.
Viewing 15 posts - 16 through 30 (of 35 total)
You must be logged in to reply to this topic. Login to reply