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?
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
Shaun Kline

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.
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
Gustav Brock

That could be a query like:

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

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Brian Sowter

ASKER
CAN I DO THIS WITH CROSSTAB?
Scott McDaniel (EE MVE )

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.
Brian Sowter

ASKER
Hi Gustav
Forgive my ignorance...Does this mean I must write the SQL code rather than use the Query designer?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Gustav Brock

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.
Brian Sowter

ASKER
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
Gustav Brock

You can only have one Select in a normal query.
See my query above.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
PatHartman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Brian Sowter

ASKER
Thanks to everybody who helped.  It is working well now!
PatHartman

You're welcome.