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:

  1. oracle
  2. mysql

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -