本文介绍了如何根据MAX条件检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的桌子:

____________________________________________________________________
****** ID ****** post_title_code ****** post_eff_date ****** site **** empno
____________________________________________________________________
****** 01 ******** 1011 ************ 01/10/1999 ******* 1070 ***** 123
****** 02 ******** 1011 ************ 01/10/2000 ******* 1070 ***** 123
****** 03 ******** 1011 ************ 01/10/2001 ******* 1070 ***** 123
****** 04 ******** 1012 ************ 01/10/2002 ******* 1070 ***** 123
****** 05 ******** 1000 ************ 01/10/2003 ******* 1070 ***** 123
****** 06 ******** 1000 ************ 01/10/2000 ******* 1070 ***** 123

现在我有不同的ID,但是post_title_codes在各个地方都相同..现在,我希望结果显示记录,但post_title_code应该是不同的,因为它应该显示ID最高的记录.
例如,上述表格的输出应为"
____________________________________________________________________
****** ID ****** post_title_code ****** post_eff_date ****** site **** empno
____________________________________________________________________
****** 03 ******** 1011 ************ 01/10/2001 ******* 1070 ***** 123
****** 04 ******** 1012 ************ 01/10/2002 ******* 1070 ***** 123
****** 06 ******** 1000 ************ 01/10/2000 ******* 1070 ***** 123

在此输出中,我们可以看到post_title_codes是不同的,并且只有显示为具有最大ID的记录才与它们分离..
就像post_title_code中"1011"的记录一样,它有3条记录,因此它显示了这3条记录中ID最高的记录..

任何帮助将不胜感激..
谢谢..

I Have a Table Like This:

____________________________________________________________________
******ID******post_title_code******post_eff_date******site****empno
____________________________________________________________________
******01********1011************01/10/1999*******1070*****123
******02********1011************01/10/2000*******1070*****123
******03********1011************01/10/2001*******1070*****123
******04********1012************01/10/2002*******1070*****123
******05********1000************01/10/2003*******1070*****123
******06********1000************01/10/2000*******1070*****123

Now i have different ID''s but the post_title_codes are same in various places..Now i want the resultant to display the record but the post_title_code should be distinct and in that it should display the record with highest ID..
E.G the output of the above mentioned Table should be like"
____________________________________________________________________
******ID******post_title_code******post_eff_date******site****empno
____________________________________________________________________
******03********1011************01/10/2001*******1070*****123
******04********1012************01/10/2002*******1070*****123
******06********1000************01/10/2000*******1070*****123

Here in this output we can see that the post_title_codes are distinct and the from them only that record is displayed which had the MAXIMUM ID..
like in post_title_code for ''1011'' had three records so it displayed the one with the highest ID among these three records..

Any help would be highly appreciated..
Thank You..

推荐答案



这篇关于如何根据MAX条件检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 16:02