imagine i have a table like this
Bikename Username NumOfUsages LastTimeOfUsage Bike1 Haldi 5 2018-12-13 12:00:00 Bike1 Torte 1 2018-08-15 12:00:00 Bike2 Haldi 3 2018-12-15 12:00:00 Bike3 Manne 2 2018-09-16 12:00:00 Bike3 Torte 5 2018-09-16 12:00:00
now i wants a Result like this
Bikename Username NumOfUsages LastTimeOfUsage Bike1 Haldi 5 2018-12-13 12:00:00 Bike2 Haldi 3 2018-12-15 12:00:00 Bike3 Torte 5 2018-09-16 12:00:00
as you can see i wants to have the Entry with the MAX NumofUsages only
Thanks for your Help so much…
Advertisement
Answer
you can use row_number()
maximum dbms support
select * from ( select *, row_number() over(partition by bikename order by NumOfUsages desc) rn from table_name )t where t.rn=1