# Board index » delphi » MATH GURU's - I need some assistance with a Query...

## MATH GURU's - I need some assistance with a Query...

I'm trying to accurately compute an Average Gross Profit Margin on a
list of transactions. I have about 200K of records and I want to
compute what each company's average profit margin is based on these
sales. I have the number of items sold, cost of each item, price each
item was sold for.

Each company has about 1000 records in my database.

How can I compute this Average Gross Profit Margin for all the sales?

Bill Artemik
--------------------
Programmer / Analyst
Wakefield Engineering, Inc.

barte...@wakefield.com

"There are THREE kinds of people in the world...
Those that can count and those that can't."

## Re:MATH GURU's - I need some assistance with a Query...

Ehh.. I'm no guru but you could try this for fun..

select company, 'margin' = avg(itemcount*(price-cost))
from transactions
group by company

--
Aigars Grins, 921 Interactive

##### Quote
Bill Artemik wrote:

> I'm trying to accurately compute an Average Gross Profit Margin on a
> list of transactions. I have about 200K of records and I want to
> compute what each company's average profit margin is based on these
> sales. I have the number of items sold, cost of each item, price each
> item was sold for.

> Each company has about 1000 records in my database.

> How can I compute this Average Gross Profit Margin for all the sales?

> Bill Artemik
> --------------------
> Programmer / Analyst
> Wakefield Engineering, Inc.

> barte...@wakefield.com

> "There are THREE kinds of people in the world...
>      Those that can count and those that can't."