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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Item grouping for packing slips
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wondering_sa
Starting Member

8 Posts

Posted - 11/06/2012 :  00:37:09  Show Profile  Reply with Quote
Hi Everybody

We ship books - no more than 10 books per box. And Other items (toys, etc.) – no more than 15 pounds per box. Books are shipped separately from Other items. But orders usually contain a mix of items (let's say: 28 Books and 34 pounds of Other items).

Is there a way to create a packing slip for every box In the case described above:


- Two boxes with 10 books each
- One box with 8 books
- Two boxes with 15 pounds of Other items each
- One box with 9 pounds of Other items


Thank you!

karthik0805
Starting Member

14 Posts

Posted - 11/06/2012 :  01:39:46  Show Profile  Reply with Quote
DECLARE @TABLE TABLE(ORDERID INT, BOOK INT, ITEM INT)
INSERT INTO @TABLE
SELECT 1,28,34
UNION ALL
SELECT 2,34,48
SELECT * FROM @TABLE
SELECT ORDERID,ITEMS,BOX_CNT FROM
(SELECT ORDERID,BOOK/10 'BOX_10_BOOKS',1 'BOX_EXTRA_BOOKS',
ITEM/15'BOX_15_POUND_ITEM',1 'BOX_EXTRA_ITEM'
FROM @TABLE)A
UNPIVOT(BOX_CNT FOR ITEMS IN(BOX_10_BOOKS,BOX_EXTRA_BOOKS,BOX_15_POUND_ITEM,BOX_EXTRA_ITEM))AS A1
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000