-1

I have two row in a table such as:

Code Amount TimeStamp
1 100 2022-08-02 16:47
1 105 2022-08-02 16:15
2 105 2022-08-02 16:15

I want max timestamp single row as output as:

Code Amount TimeStamp
1 100 2022-08-02 16:47
2 105 2022-08-02 16:15

my code:

 select code, amount, max(timeStamp) from table 
group by code, amount

1 Answers1

1

Here you don't need aggregation functions, only this:

select top 1 code, amount, timeStamp from table order by timeStamp desc
Dani
  • 1,825
  • 2
  • 15
  • 29