count function - calculations

  • Thread starter Thread starter Mitchell_Collen via AccessMonster.com
  • Start date Start date
M

Mitchell_Collen via AccessMonster.com

Hi everyone. I need expert advice.

Can one write a query that will calculate the count's average?

For example:

Select count(orders) AS Total, Total*4 AS NewTotal
From Order
Group by orders

-Misty
 
Per see, ADP are not databases but are a client interface (GUI, Frontend,
etc.) to SQL-Server. If you want to ask question specific to the sql
language or to SQL-Server then newsgroups such as m.p.sqlserver.programming
or m.p.sqlserver.server will often provide better answers than this one.

In your case, you could use the AVG aggregate function.

Also, in your exemple, you are defining an alias « Total » and reusing it
later; you cannot do that without writing a subquery:

Select SQ.Total, 4 * SQ.Total as NewTotal from (Select count(orders) AS
Total From Order Group by orders) as SQ

Order is also a reserved word, so you should enclose it in double quotes or
in [].
 
Back
Top