-4

enter image description here

I have this script in sqlserver but how can I use this logic to mySQL.. it has different syntax. Thanks in advance for the help.

Razia sultana
  • 2,168
  • 3
  • 15
  • 20

1 Answers1

1

The following should help you to use the RANK() in MySQL:

SELECT *
FROM 
    (
      SELECT [Street], [Flood],
          @curRank := @curRank + 1 AS rank
          (SELECT @curRank := 0) r
          ORDER BY [FloodCount] DESC [Ranking]
      FROM
      (SELECT [Street], [Flood], COUNT([Flood]) FROM 
      [Worklog].[dbo].[Flood]
      GROUP BY [Street], [Flood]
       ) a
    ) b
WHERE [Ranking] = 1 

For more, see this: RANK() in MySQL

Community
  • 1
  • 1
AT-2017
  • 3,114
  • 3
  • 23
  • 39