0

i am trying to fetch users list who older than and between 20 to 60 minute randomly. here is my query

SELECT * 
FROM  t_users 
WHERE create_time <= NOW() -  INTERVAL CONCAT(floor(random()* (60-20 + 1) + 20),' minutes'); 

it's giving me error ERROR: syntax error at or near "CONCAT"

1
  • 1
    this would be valid in MySQL but not in PostgreSQL world Commented Oct 5, 2020 at 13:42

1 Answer 1

1

You can't use concat() like that to create an interval. The easiest solution is to use make_interval:

WHERE create_time <= NOW() - make_interval(mins => (floor(random()* (60-20 + 1) + 20))::int )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.