简体   繁体   English

按月统计唯一记录

[英]Counting unique records by month

I'm a newbie to Access 2010. I have a table: 我是Access 2010的新手。我有一张桌子:

ID  Mth OrderID Net Sales
1   1   3   36
2   1   2   12
3   1   2   20
4   2   1   10

I'd like to get a summary by Mth of the OrderID count, Quantity of those orders, and Net Sales of the those orders: 我想按OrderID计数的Mth ,这些订单的数量以及这些订单的净销售额来获取摘要:

Mth Ordercount  Quantity    Net Sales
1   2   7   68
2   1   1   10

Is there a way to do this? 有没有办法做到这一点?

I'd also like to convert Mth = 1 into Month = Jan 2013 but have it list in date order, rather than alphabetically. 我也想将Mth = 1转换为Month = Jan 2013Mth = 1日期顺序而不是按字母顺序列出。

Mth
Jan 2013
Feb 2013

How do I do that? 我怎么做?

So far, I've only been working with the design view and have not using an SQL code. 到目前为止,我仅使用设计视图,并且未使用SQL代码。

This can be done mostly in the design viewer of access although it would require creating more than one query and using those as a source instead of a table or you could write a sub select in sql code. 尽管这将需要创建多个查询并将其用作源而不是表,但是大多数可以在Access的设计查看器中完成,或者可以在sql代码中编写子选择。

For your first question you will need to perform a distinct count on order id's based on month. 对于第一个问题,您将需要根据月份对订单ID进行不同的计数。 This question answers the same problem and will provide the output you need. 问题回答相同的问题,并将提供您需要的输出。

Once you have a query that provides the number of orders per month you can create a new query that joins the table and your query on month with Net Sales as a total field. 一旦查询提供每月订单数,您就可以创建一个新查询,该表将表和您的查询联接在一起,并将“ Net Sales作为总计字段。 Where is quantity coming from in your source data? 源数据中的数量来自哪里?

To display the month number as month access has a MonthName function you can use. 要显示月份号,因为您可以使用月份访问具有MonthName函数 You can add 2013 to this by adding & " 2013" to the end of the expression. 您可以通过在表达式末尾添加& " 2013"来添加& " 2013"

You can sort on month by adding your month field a second time for the sorting but uncheck show box. 您可以通过第二次添加月份字段来进行月份排序,但不要选中显示框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM