Advertisement

06.26.2008 at 12:35PM PDT, ID: 23519564
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Manipulating SQL Query Results, How to Transform Data Similarly to Excel Pivot Table

Asked by joshua731 in SQL Query Syntax, Microsoft Excel Spreadsheet Software, VB Script

Tags: ,

Hi Experts,

Need some help with SQL and possible Excel and/or a VB script.

I have a query that returns data with the following structure, where the first row icontains my column headers:

field1,field2,field3,field4,field5,field6,NEW,field7,field8,field9,field10,PRODUCT_PRICE
order1,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,35
order2,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,5
order3,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,15
order4,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,15
order5,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,7
order6,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,8
order7,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,15
order8,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,5
order9,order_date,order_total,p_type,cust_tag1,cust_tag2,new,p_id,p_tag,p_cat,qty,15
order10,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,11
order11,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,9
order12,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,25
order13,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,10
order14,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,45
order15,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,14
order16,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,5
order17,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,10
order18,order_date,order_total,p_type,cust_tag1,cust_tag2,old,p_id,p_tag,p_cat,qty,26

I need to manipulate this data to return a table with this structure:

Price Tier,new,old,% New to Total
5,2,0,100%
10,2,1,66%
15,4,3,57%
25,0,2,0
35,1,1,50%
45,0,1,0%

where Price Tier represents all purchases at that price point or the preceding price point;
and new is a count of all new purchases between that price tier and the preceding price tier;
and old is a count of all old purchases between that price tier and the preceding price tier;
and %New to Total is the ratio of new purchases in that price tier to all purchase (new + old) in that price tier.

I have years of data structured this way by month on individual worksheets in one Excel file.  I would like to either manipulate the results of my existing query to return the summed results as 2nd example above before I dump the data into Excel.

OR be able to run a script on all the worksheets that will return a table with the data as above.

Either way, just need a quick solution rather than using pivot tables and copy/pasting formulas by hand.

An example sheet is attached with what I am trying to get to, step-by-step.

Start Free Trial
Attachments:
 
Data Example
 
 
 
[+][-]06.26.2008 at 12:51PM PDT, ID: 21878365

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:02PM PDT, ID: 21878474

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 01:48PM PDT, ID: 21878872

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 02:48PM PDT, ID: 21879350

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, Microsoft Excel Spreadsheet Software, VB Script
Tags: SQL, SQL, Query Results, Pivot Table, Data Manipulation, Visual Basic
Sign Up Now!
Solution Provided By: nutsch
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.26.2008 at 03:25PM PDT, ID: 21879601

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628