Created
June 25, 2019 15:11
-
-
Save wmh/257cecadd67aac17d674d3c212deddd9 to your computer and use it in GitHub Desktop.
解 leetcode db 問題需要用到的一招
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, | |
@dep := dep dep, | |
@cnt := IF(@dep = dep, @cnt + 1, 1) cnt | |
FROM `emp`, | |
(SELECT @cnt := 0, @dep := 0) init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment