Solved

Convert summary list to detail list SQL MS Access

Posted on 2011-03-08
10
284 Views
Last Modified: 2012-06-22
I am looking for an efficient way to turn:

SKU   priceshed  R1 R5   W1 W5 W10 W25 W50
1099  branch       $5         $3         2.99
1089   branch      $1  .99  .75               .69
where R1 is the retail price for 1 item, W1 is the wholsale price for 1item
And turn it into

SKU  priceshed   Rate           From      To               Price
1099  Branch     Retail             1        9999              $5
1099  Branch     Wholesale     1            9                $3
1099  Branch     Wholesale     10      9999              $2.99  
1089  Branch      Retail            1          4                  $1
1089  Branch      Retail            5        9999              $3
1089  Branch     Wholesale     1         24                 $.75
1089  Branch     Wholesale      25     9999              $.69


There will always be an R1 and W1 with any combination of the rest.
9999 is the max number on the "to" count.

Right now I am using multiple queries to accomplish this. I would like to create a VB script to do the work.  Once this conversion is complete the converted table is in the same format as the production system pricing guide and then we compare the two and make changes.  The origin format is to make it easy on the person who has to update pricing on many items relatively often.

Any ideas would be greatly appreciated.

thanks
0
Comment
Question by:chenault68
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35071690
>>Zones: Microsoft Access Database, Databases Miscellaneous, MS SQL Server<<
If you are looking for a T-SQL solution, the way you would do this is with the UNION ALL clause, in other words build a series of SQL statements with a UNION ALL in between.

If on the other hand, this question is not using T-SQL than I suggest you request that the MS SQL Server zone be removed.
0
 

Author Comment

by:chenault68
ID: 35071999
You are correct  I should have added VB in the place of SQL.
0
 
LVL 8

Expert Comment

by:Andrew_Webster
ID: 35072062
Can you show us a bit more sample data from the first set, maybe even put it into an Excel sheet or something to show us how it's arranged in a table?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35074215
You should use the InStr function to parse through the each line of data. Looks like the beginning of each line starts with "SKU". Then also use the Mid() function to step through each part of the string and extract the information you want and put into the table.
I can try to put something together which may help.
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35074328
What determines the SKU 1099 vs 1089 in your string "SKU   priceshed  R1 R5   W1 W5 W10 W25 W50"?

The detail of your second line reads:
1099  Branch     Wholesale     1            9                $3

I understand the Price of $1 is from W1, but where are you getting the $3 price from? I don't see anything in the string for that. Same question for the "9".

Basically you need to use the Instr() function and/or the Mid() function to parse through your string and add the records. If the length of the string is fixed, then you only need to use the Mid() function since you can determine the fixed starting and ending lengths of the data you want to extract.
0
 
LVL 3

Accepted Solution

by:
AccessYourBiz_Com earned 500 total points
ID: 35084153
I actually created a seperate query to provide the totals and brought that into your query. See attached.
Branch-Tables-Test-by-Scott-Webe.zip
0
 

Author Closing Comment

by:chenault68
ID: 35084333
Thanks for the help
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35085321
your welcome. I actually posted that last file to the wrong thread. I am assuming you were able to find solution with the InStr() and Mid() functions.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35086283
>>your welcome. I actually posted that last file to the wrong thread<<
That is too funny!
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35086521
glad I could bring some amusement to your life ac! ;-)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question