Re: Variable constants ?

Поиск
Список
Период
Сортировка
От Charles Clavadetscher
Тема Re: Variable constants ?
Дата
Msg-id e7f1b5170944e78c11564860a5973186@swisspug.org
обсуждение исходный текст
Ответ на Re: Variable constants ?  (Rich Shepard <rshepard@appl-ecosys.com>)
Ответы Re: Variable constants ?  (Rich Shepard <rshepard@appl-ecosys.com>)
Список pgsql-general
On 2019-08-16 14:50, Rich Shepard wrote:
> On Fri, 16 Aug 2019, Charles Clavadetscher wrote:
> 
>> Another way to keep a history is using a daterange instead of two 
>> columns for start and end date. Something like
>> 
>> create table labor_rate_mult (
>>  rate         real primary_key,
>>  validity    daterange not null
>> )
> 
> Charles,
> 
> Just out of curiosity, what is the range for a rate that is still 
> current?
> Does it change every day?
> 
> Regards,
> 
> Rich

Hi Rich

That would be a range with an empty upper bound. Let's say that the rate 
is valid since 2019-08-14 then the range would look like

[2019-08-14,)

A query to find the current rate would look like:

SELECT rate
FROM labor_rate_mult
WHERE validity @> CURRENT_DATE;

Here you can find documentation on the range types (cool stuff I 
believe):

https://www.postgresql.org/docs/11/rangetypes.html

Regards
Charles

-- 
Charles Clavadetscher
Swiss PostgreSQL Users Group
Treasurer
Neugasse 84
CH – 8005 Zürich

http://www.swisspug.org

+---------------------------+
|     ____  ______  ___     |
|    /    )/      \/   \    |
|   (     / __    _\    )   |
|    \    (/ o)  ( o)   )   |
|     \_  (_  )   \ ) _/    |
|       \  /\_/    \)/      |
|        \/ <//|  |\\>      |
|             _|  |         |
|             \|_/          |
|                           |
|     Swiss PostgreSQL      |
|       Users Group         |
|                           |
+---------------------------+



В списке pgsql-general по дате отправления:

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: Variable constants ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bad Estimate for complex query with JOINS on subselects and OR in where conditions