本文介绍了按组平均MAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含3个表,联系人,蜂巢和检查的数据库,其中包含联系人ID。 联系方式 联系ID | RunGroup Hives HiveID | ContactID InspectionsNZ ContactID | HiveID |蜂巢强度|日期 每个联系人都有多个配置单元,每个配置单元都有多个检查。 我试图平均最新的蜂巢强度属于单个团体中的联系人的检查 到目前为止我已经
展开 | 选择 | 换行 | 行号 解决方案你能发布一些样本数据和结果吗?
这些是来自一组的最新检查的Hive优势: Hive Strenght |日期 0 2012/1/12 0 2012/1/12 8 2012/1/12 9 2012/1/12 5 2012/1/12 4 2012/1/12 1 2012 / 1/12 0 2012/1/12 8 2012/1/12 6 2012/1/12 0 2012/1/12 0 2012/1/12 7 2012/1/12 2 2012/1 / / 12 这应该平均为3.5但它给我的平均值为0 Group Hives |客户| Avg Hive Strength Waitakere 14 7 0 Mt Albert 18 9 5 Ponsonby 18 9 0 Manukau 20 10 8 北岸26 13 1.5 Remuera 29 15 3 Titirangi 29 15 3 Kumeu 30 13 5.458 伊甸山31 16 5.714 这是我输出数据的表
你是否尝试过没有聚合的select语句来查看它返回的记录?确保它正在将正确的记录返回到平均值
Hi, I have a database with 3 tables, Contacts, Hives, and Inspections with Contact ID as the key. Contacts ContactID | RunGroup Hives HiveID | ContactID InspectionsNZ ContactID | HiveID | Hive Strength | Date Each contact has multiple hives and each hive has multiple inspections. I am trying to average the hive strength from the latest of all inspections belonging to contacts in an individual group So far i have
Expand|Select|Wrap|Line Numbers 解决方案 Can you post some sample data and results?These are the Hive Strengths of the latest inspections from one group: Hive Strenght | Date 0 2012/1/12 0 2012/1/12 8 2012/1/12 9 2012/1/12 5 2012/1/12 4 2012/1/12 1 2012/1/12 0 2012/1/12 8 2012/1/12 6 2012/1/12 0 2012/1/12 0 2012/1/12 7 2012/1/12 2 2012/1/12 This should average 3.5 but it is giving me and average of 0 Group Hives|Customers|Avg Hive Strength Waitakere 14 7 0 Mt Albert 18 9 5 Ponsonby 18 9 0 Manukau 20 10 8 North Shore 26 13 1.5 Remuera 29 15 3 Titirangi 29 15 3 Kumeu 30 13 5.458 Mt Eden 31 16 5.714 This is the table i am outputting the data tooHave you tried the select statement without the aggregation to see what records it returns? To make sure it''s returning the correct records to average on??更多推荐
按组平均MAX
发布评论