Question : How to substract a smaller subrange from a bigger range? 123456789 567 Result: 1234 89 SQL: select ‘[1,9]’::int4range […]
Tag: range-types
Placing a uniqueness constraint on a date range
Question : I have a table reservation with columns roomno(INTEGER), startdate(DATE), enddate(DATE) with a primary key on (roomno, startdate). How […]
Counting working days in a month
Question : I wrote this query that suppose to count the working days in a month but I get the […]
PostgreSQL – Datetime ranges overlap
Question : I have a table with datetime fields start and end. And I have a list of (start, end) […]
Measure time duration between events, partitioned by hours
Question : I have the following table in PostgreSQL 9.4, which persists users log on/off events (log on is event_type […]
Foreign key on PostgreSQL range bounds
Question : Is it possible in PostgreSQL 9.6 to apply a foreign key constraint on the lower and upper bounds […]
generate series of time ranges
Question : I know we can use Postgres’s generate_series() function to produce a list of timestamps. Can we do the […]
PostgreSQL – Datetime ranges overlap
Question : I have a table with datetime fields start and end. And I have a list of (start, end) […]
How to search one bible verse from a source that may contain ranges?
Question : My WordPress system contains posts with a field containing Bible references and ranges, eg. John 5,1-10; Matthew 3,2; […]
How to handle bad query plan caused by exact equality on range type?
Question : I’m performing an update where I require an exact equality on a tstzrange variable. ~1M rows are modified, […]