Top 10 list
by chudson007 » Wed, 30 Jul 2003 17:05:07 GMT
Hi,
I'm new to access and have two quick questions.
1) I've got a table with a couple of hundred thousand lines.
Each line contains a product number, quantity and price among other
things. How do I insert a field that multiplies the price by the
quantity.
2) each product appears on several lines. I want to pull out the top
ten products firstly by value (price * quantity) and then by frequency
(the sum of the quantities on each line)
Thanks in advance,
Ciar
Re: Top 10 list
by Mike MacSween » Wed, 30 Jul 2003 21:21:08 GMT
You don't store data that can be calculated from other data. Run a query
against the table instead. I've assumed some table and field names:
SELECT tblSales.Product, tblSales.Price, tblSales.Quantity,
[Price]*[Quantity] AS [Value]
FROM tblSales;
Not quite sure whether you want 2 different things here. Anyway, this will
give you the top ten products by value, and how many of those top 10 you
sold:
SELECT TOP 10 tblSales.Product, Sum([Price]*[Quantity]) AS [Value],
Sum(tblSales.Quantity) AS [TotalSold]
FROM tblSales
GROUP BY tblSales.Product
ORDER BY Sum([Price]*[Quantity]) DESC;
HTH, Mike MacSween
Re: Top 10 list
by chudson007 » Thu, 31 Jul 2003 16:17:13 GMT
Cheers Mike, That worked perfectly.
Appreciate it.
Ciar
Re: Top 10 list
by chudson007 » Thu, 07 Aug 2003 17:07:40 GMT
Here is my query
SELECT TOP 200 sales.Ean, Sum(sales.Qty) AS TotalSold,
Sum([sales].[Price]*[sales].[Qty]) AS [Value], sales.Name
FROM sales
GROUP BY sales.Ean, sales.Name
ORDER BY Sum([sales].[Price]*[sales].[Qty]) DESC;
It works fine, except that the result of Sales * Qty has no
consistency in how many decimal places it has.
How do I specify that the result should be to 2 decimal places.
Ciar
Re: Top 10 list
by Mike MacSween » Wed, 13 Aug 2003 01:09:17 GMT
Similar Threads:
1.can you limit the amount of data in a Query (Top 10 list)
If I do a query that gives me 50 lines of data and I only want the top 10
lines how would one do this?
2.Multiple "top 10" listing
Is it possible to have a query return the top 10 items in multiple
categories? For instance, say I have a table with salesman id, product
category, customer, and price. Can I get the top 10 customers per customer
or per category? If I select the dropdown in the query design and put in
10, I just get 10 rows.
Thanks,
Brian
3.Top 10 Percent / Top 10 Values
Hi,
I have a query, and within the query I want to limit the result set by
adding criteria.
I have an if statement which says iif([debt-code]>100,True,False). What I
want to say is if the [debt-code] value is >100 then give me TOP 10 PERCENT
or TOP 10 VALUES. I have tried to add this to the if statement but it does
not work. Can anyone tell me how to do this in an if statement???
Thanks
Paul
4.Selecting top 10 from a list
Is there an easy way to write a query that will select the
top ten from a list. For example say you have a number of
sales reps working for you and you want to know who were
the top ten performers for the last month. All the data is
loaded in a relevant table in an access database in which
a query can be written to give an output with the
following headings:
Month Rep_Name Sales_Revenue
5.How can I retrieve rows from 11 to 20 ( Selete TOP 10 gives first 10)
6. SELECT TOP 10 -- then get next 10?
7. Top 10 Home Based Businesses
8. Top 10 Worst Access Pick-Up Lines