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.
Asked
Active
Viewed 41 times
-4
-
post code instead of image. And maybe add what you have tried – Suraj Rao Dec 13 '16 at 04:50
-
also give the source data and desired output, it'll be much easier to give the solution based on that – kapilpatwa93 Dec 13 '16 at 04:57
1 Answers
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