Skip to content

Instantly share code, notes, and snippets.

@wmh
Created June 25, 2019 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmh/257cecadd67aac17d674d3c212deddd9 to your computer and use it in GitHub Desktop.
Save wmh/257cecadd67aac17d674d3c212deddd9 to your computer and use it in GitHub Desktop.
解 leetcode db 問題需要用到的一招
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