Postgre subquery help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ktrw25
    New Member
    • Feb 2007
    • 17

    #1

    Postgre subquery help

    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;
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Originally posted by ktrw25
    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);

    Comment

    • ktrw25
      New Member
      • Feb 2007
      • 17

      #3
      Thanks, worked great.

      Comment

      Working...