Advertisement

07.18.2008 at 12:40PM PDT, ID: 23577997
[x]
Attachment Details

ht return sales percentages and counts in buckets? MS SQL SERVER 2000

Asked by ottenm in MS SQL Server

I'm looking for a way to summarize the sales figures in a table containing about 75,000 records.  I'd like to end up with one row for each sales rep and 2 columns for each of the following price "buckets": $0-1,000 and $1-3,000 and $3-10,000 and $10,000+.  For each of those ranges, I need to know the percentage of orders for that rep that fall within that range, and a count of how many orders for that rep that fall into that range (these are the 2 columns per bucket).

I need to exclude all orders with totalprice < $10.  And I need to pass in a start date and an end date.  But sometimes this range will include everything in the table.

The tables are: order_entry with PK job_number (int), totalprice (decimal), entry_date (datetime), and sales_rep_emp_number (int).  And I would like to display the rep's names which are in the employees table with PK employee_number (int)

If it's easy to include the following grand total columns as the last columns, that would also be awesome: sum of all sales for that rep, count of all sales, average sale price.

All that, and a chocolate donut, would absolutely make my day.Start Free Trial
 
 
[+][-]07.18.2008 at 04:19PM PDT, ID: 22040587

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.

 
[+][-]07.19.2008 at 07:46AM PDT, ID: 22042617

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

Zone: MS SQL Server
Sign Up Now!
Solution Provided By: mark_wills
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.19.2008 at 01:10PM PDT, ID: 22043558

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.

 
[+][-]07.19.2008 at 01:55PM PDT, ID: 22043639

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.

 
[+][-]07.22.2008 at 10:25AM PDT, ID: 22061589

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.

 
[+][-]07.22.2008 at 10:37AM PDT, ID: 22061701

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.

 
[+][-]07.22.2008 at 12:18PM PDT, ID: 22062673

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