count function - calculations

  • Thread starter Mitchell_Collen via AccessMonster.com
  • 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
 
M

Mitchell_Collen via AccessMonster.com

also, I forgot to mention that this is a adp database.
 
S

Sylvain Lafontaine

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 [].
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top