本文介绍了根据我的情况对桌子排序...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据表中特定项目的最后一个条目对记录进行排序.
i want to sort my record according to last entry of particular items in table.
ITEMS PRODUCT DATE
-------------------------------------------------
mobile nokia 01/10/2012
mobile nokia 02/10/2012
mobile nokia 03/10/2012
bottle water 05/10/2012
bottle water 06/10/2012
pen blackpen 08/10/2012
pen blackpen 09/10/2012
pen blackpen 12/10/2012
输出以这种方式来
the output comes in this manner
ITEMS PRODUCT DATE
-------------------------------------------------
mobile nokia 03/10/2012
bottle water 06/10/2012
pen blackpen 12/10/2012
告诉我查询
tell me the query
推荐答案
select Item,Product,max(date) from tbl group by Item,Product
祝您编码愉快!
:)
Happy Coding!
:)
select * from Tablename order by DATE Asc
忽略上面的代码,并尝试使用此更新的代码,它将起作用
ignore above code and Try this updated code it will work
select Items,Product,max(MYdate) from Tablename group by Items,Product
SELECT ITEMS,PRODUCT,Date FROM (SELECT ITEMS,PRODUCT,Date,
ROW_NUMBER() OVER(PARTITION BY ITEMS,PRODUCT ORDER BY Date) As ROWNUM
FROM tbl ) AS A WHERE A.ROWNUM = 2
谢谢
Thank you
这篇关于根据我的情况对桌子排序...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!