Link to home
Start Free TrialLog in
Avatar of Brian Sowter
Brian Sowter

asked on

Revenue and volume by type number

I have an access 360 data base of about 10000 orders.  Each record (order) shows the type number ordered, the quantity and total price. Only one type number per order.   How can I make a query which shows the total revenue and quantity by type number?
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Is revenue something other than Quantity * Price?

If you want to run this across all orders, you would use the above calculation and group by Type Number, excluding all other columns.
Avatar of Brian Sowter
Brian Sowter

ASKER

Could you please get me started with groups.  I already have revenue as a field. I have generated a table of type numbers
That could be a query like:

Select
    [type number],
    Sum([quantity]),
    Sum([revenue])
From
    YourTable
Group By
    [type number]

Open in new window

CAN I DO THIS WITH CROSSTAB?
You can use GROUP BY and various aggregate functions to create a query. For example, to SUM by Quantity over a specific Group:

SELECT SUM(SomeField) FROM YourTable GROUP BY YourGroupField

In your case, if you want to sum the quantity:

SELECT [Type Number], SUM(Quantity) FROM YourOrdersTable GROUP BY [Type Number]

To get the Revenue:

SELECT [Type Number],  SUM(Quantity * UnitPrice) FROM YourOrdersTable GROUP BY [Type Number]

Of course you'd have to change Table and Column names to match your project.
Hi Gustav
Forgive my ignorance...Does this mean I must write the SQL code rather than use the Query designer?
That's up to you.
Open a new query, go to SQL view, paste the code, and edit it to match you table and field names.
Then you can switch to the design view to study.
This is my code:

SELECT SUM([Qty])  FROM Query1 GROUP BY [Type]

SELECT [Type], SUM([Qty]) FROM Query1 GROUP BY[Type]

SELECT [Type],  SUM([Value] FROM Query1 GROUP BY [Type]

I get  "Syntax error in query expression '[Type] SELECT [Type]" after saving
You can only have one Select in a normal query.
See my query above.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks to everybody who helped.  It is working well now!
You're welcome.