如何从每个产品编号获得最新的运行?

时间:2021-11-03 21:32:20

I have a table with products A,B,C,D and each products has been tested 1 time, so the my table as product A run 1, B run 1, C run 1, D run 1, now product A needed a specific test run 1 more time and C run 3 more times so now my tables has A run 1, A run 2, B run 1, C run 1, C run 2, C run 3, C run 4, D run 1.

我有一个产品A,B,C,D的表,每个产品都经过1次测试,所以我的表作为产品A运行1,B运行1,C运行1,D运行1,现在产品A需要一个特定的测试运行1次以上,C再运行3次,所以现在我的表有A运行1,运行2,B运行1,C运行1,C运行2,C运行3,C运行4,D运行1。

My attempts so far was separating information into groups then using join from left, right and inner but it keeps pulling the wrong rows of information or adds up the values. I also tried google in attempt to find the best way to tackle this because I'm going to be dealing with a lot of rows of data so I need it be effective and efficient but still no luck.

到目前为止,我的尝试是将信息分成组,然后使用左,右和内的连接,但它不断拉出错误的信息行或添加值。我也尝试谷歌试图找到解决这个问题的最佳方法,因为我将处理大量的数据行,所以我需要它有效和高效,但仍然没有运气。

So my question is how do I get all the products to show up in a table with only the latest run when they are all currently in the same table ?

所以我的问题是如何将所有产品显示在一个只有最新运行的表中,当它们都在同一个表中时?

1 个解决方案

#1


0  

Normally a sample of what you have tried or your data structure would be helpful to providing you information, but I think this is what you are looking for. It looks like you were missing the group by.

通常情况下,您尝试过的样本或数据结构将有助于为您提供信息,但我认为这正是您所寻找的。看起来你错过了这个小组。

Select product, Max(run) from table_name group by product

#1


0  

Normally a sample of what you have tried or your data structure would be helpful to providing you information, but I think this is what you are looking for. It looks like you were missing the group by.

通常情况下,您尝试过的样本或数据结构将有助于为您提供信息,但我认为这正是您所寻找的。看起来你错过了这个小组。

Select product, Max(run) from table_name group by product