U
U
un1t2017-06-08 15:27:26
PostgreSQL
un1t, 2017-06-08 15:27:26

Postgres - several unions with almost the same query, how to simplify?

Is it possible to somehow simplify the request so as not to copy-paste the same thing 10 times?

select distinct on (z) h 40, t.* from t where h > 40
union
select distinct on (z) h 50, t.* from t where h > 50
union
...
union
select distinct on (z) h 60, t.* from t where h > 150

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question