oracle - Rank function in MySQL with Order By clause -
how (oracle) sql:
select a.*, rank() on (partition a.field1 order a.field2 desc) field_rank table_a order a.field1, a.field2 be translated mysql?
this question seems similar there no order in end of base query. also, matter ordered fields of partition?
according link gave should this:
select a.*, ( case a.field1 when @curtype @currow := @currow + 1 else @currow := 1 , @curtype := a.field1 end ) + 1 rank table_a a, (select @currow := 0, @curtype := '') r order a.field1, a.field2 desc; here 2 fiddles, 1 oracle , 1 mysql based on example link gave:
Comments
Post a Comment