Skip to content

Instantly share code, notes, and snippets.

@Goryudyuma
Created February 28, 2018 07:40
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 Goryudyuma/1d70a0bce8521e7cc6515fd9850d577e to your computer and use it in GitHub Desktop.
Save Goryudyuma/1d70a0bce8521e7cc6515fd9850d577e to your computer and use it in GitHub Desktop.
MISQUERY ONLINE
WITH RECURSIVE solve(strrow,str) AS (
SELECT str,str
FROM tbl
UNION ALL
SELECT strrow,REPLACE(REPLACE(REPLACE(str, '()', ''),'{}',''),'[]','')
FROM solve
WHERE str!=REPLACE(REPLACE(REPLACE(str, '()', ''),'{}',''),'[]','')
)
SELECT i,
CASE WHEN str IN
(
SELECT strrow
FROM solve
WHERE str = ''
) THEN 'YES'
ELSE 'NO'
END AS judgement
FROM tbl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment