Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enumerate (expand) dataset dependent on number in data field

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
I have this data

Code:
P/N	Version	CageCode	Customer	JobDescription	SO #	PL #	StockDescription	SalesOrderLine	PO #	QTY#	WO #	BuildDate	ITEM #
B332182-111	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	11	102612-00                     	1	331832	2015-06-29	ITEM 06                                      
B332182-115	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	13	102612-00                     	1	331833	2015-06-29	ITEM 07                                      
B332182-119	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	15	102612-00                     	1	331834	2015-06-29	ITEM 08                                      
B332182-121	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	17	102612-00                     	2	331835	2015-06-29	ITEM 09                                      
B332182-122	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	19	102612-00                     	2	331836	2015-06-29	ITEM 10                                      
B332182-123	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	21	102612-00                     	1	331837	2015-06-29	ITEM 11                                      
B332182-124	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	23	102612-00                     	1	331838	2015-06-29	ITEM 12                                      
B332182-125	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	25	102612-00                     	8	331839	2015-06-29	ITEM 13                                      
B332182-126	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	27	102612-00                     	8	331840	2015-06-29	ITEM 14                                      
B332182-127	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46477	PL121525	CARPET, RECON, B777-200ER     	29	102612-00                     	1	331841	2015-06-29	ITEM 15                                      
B332182-129	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	1	102613-00                     	1	331842	2015-06-29	ITEM 01                                      
B332182-131	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	3	102613-00                     	1	331843	2015-06-29	ITEM 02                                      
B332182-133	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	5	102613-00                     	1	331844	2015-06-29	ITEM 03                                      
B332182-135	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	7	102613-00                     	8	331845	2015-06-29	ITEM 04                                      
B332182-137	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	9	102613-00                     	1	331846	2015-06-29	ITEM 05                                      
B332182-138	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	11	102613-00                     	1	331847	2015-06-29	ITEM 06                                      
B332182-139	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	13	102613-00                     	1	331848	2015-06-29	ITEM 07                                      
B332182-141	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	15	102613-00                     	8	331849	2015-06-29	ITEM 08                                      
B332182-143	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	17	102613-00                     	1	331850	2015-06-29	ITEM 09                                      
B332182-145	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	19	102613-00                     	1	331851	2015-06-29	ITEM 10                                      
B332182-147	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	21	102613-00                     	1	331852	2015-06-29	ITEM 11                                      
B332182-149	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	23	102613-00                     	1	331853	2015-06-29	ITEM 12                                      
B332182-151	-  	6S626	FLIG01	CARPET, RECON, B777-200ER     	46478	PL121526	CARPET, RECON, B777-200ER     	25	102613-00                     	8	331854	2015-06-29	ITEM 13

from which I need to print labels, so... I need to add another field to pair with QTY# and count up to QTY#, so 1 of 8, 2 of 8, 3 of 8 etc. I had thought of using something like row_number(), but wasn't sure of any nice way within SQL to do the expansion (Creating additional records). Thoughts?

Thanks,
Willie
 
I got it to work

Code:
SELECT [P/N]
      ,[Version]
      ,[CageCode]
      ,[Customer]
      ,[JobDescription]
      ,[SO #]
      ,[PL #]
      ,[StockDescription]
      ,[SalesOrderLine]
      ,[PO #]
      ,dbo.tblCount.[Count]
      ,[QTY#]
      ,[WO #]
      ,[BuildDate]
      ,[ITEM #]
  FROM [dbo].[view_FSIForDusty] INNER JOIN
          dbo.tblCount ON dbo.[view_FSIForDusty].QTY# >= dbo.tblCount.[Count]
 
It's unclear from the data you present what the proper relationships are, and what the source of each field is. Also, what's the structure of the view, and the structure of the table tblCount? Should the quantities be related or summed by SalesOrderLine? SO#? WO#? What results do you expect to see?

I'd go on, but it's better that I refer you to Mr. Broadbent's Ancient FAQ.

-----------
With business clients like mine, you'd be better off herding cats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top