[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Convert summary list to detail list SQL MS Access

Posted on 2011-03-08
10
Medium Priority
?
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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