sql server - Select only maximum value record for multiple rows -


i have 1 table, having records like,

unit    rate    dateeffected ------------------------------------------- alha    ils     2014-03-02 00:00:00.000 alha    ils     2014-08-02 00:00:00.000 buck    ils     2013-02-14 00:00:00.000 buck    ils     2014-03-02 00:00:00.000 buck    ils     2014-08-02 00:00:00.000 casc    ild     2013-02-14 00:00:00.000 casc    ild     2014-03-02 00:00:00.000 casc    ild     2014-08-02 00:00:00.000    

now, want maximum date value record selection in result table. is,

unit    rate    dateeffected ------------------------------------------- alha    ils     2014-08-02 00:00:00.000 buck    ils     2014-08-02 00:00:00.000 casc    ild     2014-08-02 00:00:00.000    

hope helps.

select  unit,  rate, max(dateeffected) maxdateeffected tablename group  unit,rate 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -