[SQL] Check set of date intervals

2010-05-27 Thread Anton Gavazuk
Hi all, have such relation A: PERIOD_ID | DATE_START | DATE_END | OTHER_ATTRIBUTES... 1 | 01.01.2010 | 01.02.2010 2 | 03.02.2010 | 04.03.2010 . .. I want to search among periods for the set of periods which completely covers passed search

[SQL] checking the gaps in intervals

2012-10-05 Thread Anton Gavazuk
Hi dear community, Have probably quite simple task but cannot find the solution, Imagine the table A with 2 columns start and end, data type is date start end 01 dec. 10 dec 11 dec. 13 dec 17 dec. 19 dec . If I have interval, for example, 12 dec-18 dec, how can I

Re: [SQL] sql basic question

2012-12-28 Thread Anton Gavazuk
Do the child Select min, max from... Group by side Then you can do whatever is required... Thanks, Anton On Dec 28, 2012, at 12:23, Antonio Parrotta antonioparro...@gmail.com wrote: Hi All, I have this table: LABEL ID Distance SIDE 15; 119006;

Re: [SQL] sql basic question

2012-12-28 Thread Anton Gavazuk
be included in the query. Thanks - Antonio On 28 December 2012 12:38, Anton Gavazuk antongava...@gmail.com wrote: Do the child Select min, max from... Group by side Then you can do whatever is required... Thanks, Anton On Dec 28, 2012, at 12:23, Antonio Parrotta antonioparro...@gmail.com

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Anton Gavazuk
Hi Jorge, Look on http://www.postgresql.org/docs/8.1/static/functions-conditional.html Thanks, Anton On Feb 6, 2013, at 0:23, JORGE MALDONADO jorgemal1...@gmail.com wrote: I have an UPDATE query with the following general structure: UPDATE table1 SET (SELECT field FROM table2 WHERE

Re: [SQL] Correct implementation of 1:n relationship with n0?

2013-04-30 Thread Anton Gavazuk
Hi, Can you explain what you are trying to achieve because it's not clear... There are 2 types of relationships which might be used in your case: 1) unidirectional relationship from list_item to list through foreign key on list 2) bidirectional relationship implemented through join table which

Re: [SQL] Advice on key design

2013-07-23 Thread Anton Gavazuk
Hi Jorge, In your case it would be lpp_id as PK, and lpp_person_id,lpp_language_id as unique constraint Thanks, Anton On Jul 23, 2013, at 23:45, JORGE MALDONADO jorgemal1...@gmail.com wrote: I have 2 tables, a parent (tbl_persons) and a child (tbl_languages_per_person) as follows (a

Re: [SQL] Advice on key design

2013-07-24 Thread Anton Gavazuk
, Anton Is there a reason to do it the way you suggest? Regards, Jorge Maldonado On Tue, Jul 23, 2013 at 5:02 PM, Anton Gavazuk antongava...@gmail.comwrote: Hi Jorge, In your case it would be lpp_id as PK, and lpp_person_id,lpp_language_id as unique constraint Thanks, Anton On Jul 23