A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Count records within a range of values



 
 
Thread Tools Display Modes
  #1  
Old May 24th, 2004, 07:51 PM
Steve
external usenet poster
 
Posts: n/a
Default Count records within a range of values

Please help me. I have a table with fields Salesman, Customer, Comparison(% of sales volume compared to last quarter). I would like a query that gives the count by salesman of the number of customers with sales in 4 ranges. =50%, between 51 and 100, between 101 and 150 and 150%. How can I do this with one query?
  #2  
Old May 25th, 2004, 01:16 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default Count records within a range of values

Hi,


TRANSFORM COUNT(*)
SELECT salesman
FROM myTable
GROUP BY salesman
PIVOT SWITCH( comparison=.5, "50%",
comparison=1, "51-100%",
comparison=1.5, "101-150%",
TRUE, "150%" )



or similar, should do. A more versatile solution is to enter the constants
in a table, to make an inner join with that table, and change the PIVOT
clause accordingly.


TRANSFORM COUNT(*)
SELECT salesman
FROM myTable INNER JOIN scale
ON myTable.Comparison BETWEEN scale.Low AND scale.High
GROUP BY salesman
PIVOT scale.Description




Hoping it may help,
Vanderghast, Access MVP





"Steve" wrote in message
news
Please help me. I have a table with fields Salesman, Customer,
Comparison(% of sales volume compared to last quarter). I would like a
query that gives the count by salesman of the number of customers with sales
in 4 ranges. =50%, between 51 and 100, between 101 and 150 and 150%. How
can I do this with one query?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.