ORDER BY(SALES除以ORDERS)ASC [英] ORDER BY (SALES divided by ORDERS) ASC

查看:86
本文介绍了ORDER BY(SALES除以ORDERS)ASC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我在网上卖三明治,我正在尝试创建一个asp页面,我可以查看我的销售情况,找出谁是我最好的客户和等等...

我的表(客户)列出了同一客户订购的次数(ORDERS)和他花的总金额(SALES)。

现在,我想计算一下客户的平均支出:SALES除以ORDERS。

sql =" ; SELECT * FROM CUSTOMERS ORDER BY SALES / ORDERS ASC"

这是我的sql声明,当然,它不起作用,请帮助我。


- 我不想在我的数据库中添加另一列,因为它已经足够大了。

- 我需要计算sql中的平均值,以便我可以订购我的结果升序或降序。


谢谢!

Hello,

I''m selling sandwiches online and I''m trying to create a asp page where I can review my sales and found out who is my best customers and so on...

My table (CUSTOMERS) lists the number of times a same customer ordered (ORDERS) and the total amount of money he spent (SALES).

Now, I''d like to calculate my customer''s average spending : SALES divided by ORDERS.

sql="SELECT * FROM CUSTOMERS ORDER BY SALES/ORDERS ASC"
This is my sql statement and of course, it doesn''t work, please help me.

- I prefer not adding another column in my database cause it''s already huge enough.
- I need to calculate the average in the sql so that I can order my results ascending or descending.

Thank you!

推荐答案


您好,


我是lling三明治在线,我正在尝试创建一个asp页面,我可以查看我的销售情况,找出谁是我最好的客户等等......

我的桌子(客户)列出同一客户订购的次数(ORDERS)和他花的总金额(SALES)。

现在,我想计算我的客户平均支出:SALES除以ORDERS。

sql =" SELECT * FROM CUSTOMERS ORDER BY SALES / ORDERS ASC"

这是我的sql语句,当然,它不起作用,请帮助我。


- 我不想在我的数据库中添加另一列,因为它是'已经够大了。

- 我需要计算sql中的平均值,以便我可以按升序或降序对结果进行排序。


谢谢!
Hello,

I''m selling sandwiches online and I''m trying to create a asp page where I can review my sales and found out who is my best customers and so on...

My table (CUSTOMERS) lists the number of times a same customer ordered (ORDERS) and the total amount of money he spent (SALES).

Now, I''d like to calculate my customer''s average spending : SALES divided by ORDERS.

sql="SELECT * FROM CUSTOMERS ORDER BY SALES/ORDERS ASC"
This is my sql statement and of course, it doesn''t work, please help me.

- I prefer not adding another column in my database cause it''s already huge enough.
- I need to calculate the average in the sql so that I can order my results ascending or descending.

Thank you!

假设


包含字段的表

CustomerID .........数据类型........数字

销售....................数据类型.......货币

按照每个客户的原则单独销售金额列在名为customers的表中以及他们的客户ID ...然后以下SQL将显示他们的客户ID,该客户ID的总数(因此将其作为订单总额映射)然后是每个单独销售项目的总和,最后是销售总额的四舍五入平均值除以总订单(客户ID计数)


显然,如果这不符合您的特定表格,那么我相信您可以修改以适应。

Assumptions

Table having fields
CustomerID......... datatype........ Number
Sales.................... datatype....... Currency

Working off the principle individual sale amount per customer are listed in the table called customers along with their customer ID... then the following SQL will display their customer id, the total count of that customer id (which maps out therefore as an order total) then the total sum of each individual sale item and lastly the rounded average of your sales total divided by the total order (customer Id count)

Obviously if this doesnt resemble your particular table then I''m sure you can amend to suit.

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号



您好,


我在网上卖三明治,我正在尝试创建一个asp页面,我可以查看我的销售情况,发现谁是我的最好的客户等...

我的表(客户)列出了同一客户订购的次数(订单)和他花的总金额(SALES)。

现在,我想计算一下客户的平均消费:SALES除以ORDERS。

sql =" SELECT * FROM CUSTOMERS ORDER BY SALES / ORDERS ASC"

这是我的sql声明,当然,它不起作用,请帮助我。


- 我不希望在我的数据库中添加另一列导致它已经够大了。

- 我需要计算sql中的平均值,以便我可以按结果升序或降序排序。


谢谢!
Hello,

I''m selling sandwiches online and I''m trying to create a asp page where I can review my sales and found out who is my best customers and so on...

My table (CUSTOMERS) lists the number of times a same customer ordered (ORDERS) and the total amount of money he spent (SALES).

Now, I''d like to calculate my customer''s average spending : SALES divided by ORDERS.

sql="SELECT * FROM CUSTOMERS ORDER BY SALES/ORDERS ASC"
This is my sql statement and of course, it doesn''t work, please help me.

- I prefer not adding another column in my database cause it''s already huge enough.
- I need to calculate the average in the sql so that I can order my results ascending or descending.

Thank you!



试试这个,看看是否有帮助:

Try this and see if it helps:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号



试一试,看看是否有帮助:
Try this and see if it helps:
展开 | 选择 | 换行 | 行号


这篇关于ORDER BY(SALES除以ORDERS)ASC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆