Solved

Convert summary list to detail list SQL MS Access

Posted on 2011-03-08
10
281 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Backup Your Microsoft Windows Server®

Backup 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.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now