将相似项目分组并存储最长时间

将相似项目分组并存储最长时间

本文介绍了将相似项目分组并存储最长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一张表格,其中包含一天中不同时段的不同物料质量和整数.在所有不同的时间采样.
基本上,我想将相似的回合的样本分析加在一起,并显示最新的样本日期.

举例说明:

表格:

Date_Time轮次没有Batch_Mass

17/02/2012 15:42:35 16 500
17/02/2012 15:38:35 16400
17/02/2012 15:33:35 15 200


正确的输出为:

Date_Time轮次没有Batch_Mass

17/02/2012 15:42:35 16 900
17/02/2012 15:33:35 15 200

基本上,第16轮的最新时间是2012年2月17日15:42:35,累积质量为900

谢谢大家!

Hi Guys,

I have a table containing different materials masses and round numbers over different periods of the day. Samples are taken at all different times.
Basically I would like to add the sample analysis for similiar rounds together, and display however the latest sample date.

To illustrate:

Table:

Date_Time Round No Batch_Mass

17/02/2012 15:42:35 16 500
17/02/2012 15:38:35 16 400
17/02/2012 15:33:35 15 200


The correct output would be:

Date_Time Round No Batch_Mass

17/02/2012 15:42:35 16 900
17/02/2012 15:33:35 15 200

Basically, the latest time for round number 16 was 17/02/2012 15:42:35 and the cumulative mass was 900

Thanks Guys!!

推荐答案


SELECT  ROUND_NUMBER,sum(BATCH) as total, max(sample_date) as latest
FROM test
GROUP BY round_number;



ROUND_NUMBER TOTAL LATEST
---------------------- ---------------------- ------ -------------------

16900 2012-02-17 09:02:43
15200 2012-02-17 08:02:14

谢谢.



ROUND_NUMBER TOTAL LATEST
---------------------- ---------------------- -------------------------

16 900 2012-02-17 09:02:43
15 200 2012-02-17 08:02:14

Thanks..


这篇关于将相似项目分组并存储最长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 06:42