By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Postgre subquery help

P: 17
Is there a better way to write the statement below with postgre. It works fine, wondering if there might be a way with with only 1 extract. I just need only results returned if they fall on a 10 minute interval. Thanks.

SELECT * FROM t1
WHERE EXTRACT(minute FROM timestamp) = 0 OR
EXTRACT(minute FROM timestamp) = 10 OR
EXTRACT(minute FROM timestamp) = 20 OR
EXTRACT(minute FROM timestamp) = 30 OR
EXTRACT(minute FROM timestamp) = 40 OR
EXTRACT(minute FROM timestamp) = 50;
Jan 20 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 700
Is there a better way to write the statement below with postgre. It works fine, wondering if there might be a way with with only 1 extract. I just need only results returned if they fall on a 10 minute interval. Thanks.

SELECT * FROM t1
WHERE EXTRACT(minute FROM timestamp) = 0 OR
EXTRACT(minute FROM timestamp) = 10 OR
EXTRACT(minute FROM timestamp) = 20 OR
EXTRACT(minute FROM timestamp) = 30 OR
EXTRACT(minute FROM timestamp) = 40 OR
EXTRACT(minute FROM timestamp) = 50;
maybe it would work
SELECT * FROM t1
WHERE EXTRACT(minute FROM timestamp) in (0,10,20,30,40,50);
Jan 20 '08 #2

P: 17
Thanks, worked great.
Jan 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.