Created
March 6, 2013 06:03
-
-
Save cjpartridgeb/5097086 to your computer and use it in GitHub Desktop.
This file contains 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 subscriptions.id, subscriptions.agency_id, subscriptions.expiry, | |
CASE | |
WHEN subscriptions.expiry > date_part('epoch'::text, now())::bigint THEN 'current'::text | |
ELSE 'expired'::text | |
END AS status | |
FROM subscriptions | |
ORDER BY subscriptions.expiry DESC; | |
-- This returns: | |
-- 25;1;1394321699;"current" | |
-- 25;1;1394321627;"current" | |
-- 23;1;1361057708;"expired" | |
-- 26;1;1296767409;"expired" | |
-- Is there an easy way to return "current" for the actual current, and "future" for any after | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment