?
Solved

Convert summary list to detail list SQL MS Access

Posted on 2011-03-08
10
Medium Priority
?
287 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 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