Skip to content

Instantly share code, notes, and snippets.

@MikeMKH
Last active August 29, 2015 14:07
Show Gist options
  • Save MikeMKH/a5ca6668f5ef290ab507 to your computer and use it in GitHub Desktop.
Save MikeMKH/a5ca6668f5ef290ab507 to your computer and use it in GitHub Desktop.
Getting the values of 2 and 4 from an infinite sequence of numbers.
(->> (range) (rest) (filter even?) (take 2))
DECLARE
@min AS INT = 0
,@max AS INT = 100
;WITH [range] AS (
SELECT @min AS num
UNION ALL
SELECT num + 1 FROM [range] WHERE num < @max
)
SELECT TOP 2 *
FROM [range]
WHERE num > 0
AND (num % 2) = 0
;
@MikeMKH
Copy link
Author

MikeMKH commented Sep 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment