commit 23a7fbea6a0edf476a8c26074c6c8d60847a200e parent ce2af72e838f135022bb054d1340a4f7e5c26be0 Author: AndrewLockVI <andrewlaack1@gmail.com> Date: Mon, 10 Jul 2023 08:34:10 -0500 Completed consecutive numbers using mySQL Diffstat:
| A | consecutive-numbers/consecutive-numbers.sql | | | 10 | ++++++++++ |
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/consecutive-numbers/consecutive-numbers.sql b/consecutive-numbers/consecutive-numbers.sql @@ -0,0 +1,10 @@ +--Return all numbers that occur at least 3 times consecutively +--where they are ordered by their id. + +SELECT Logs.num ConsecutiveNums +FROM Logs +WHERE Logs.num = (SELECT L.num FROM Logs as L +WHERE L.id = Logs.id + 1) +AND Logs.num = (SELECT L.num FROM Logs as L +WHERE L.id = Logs.id + 2) +GROUP BY Logs.num