Re: [sqlite] SQL Statement Help(selecting days).

2011-05-19 Thread Jean-Christophe Deschamps
> > Since we use recursive triggers, set recursive_triggers pragma > > beforehand if not yet done. > >Cunning. A bit of a Rube Goldberg apparatus though, no? Huh? Still way more flexible than having to modify C source of a vtable module, should you have to adapt anything. Yeah, it's kind of

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-19 Thread Petite Abeille
On May 19, 2011, at 11:44 AM, Jean-Christophe Deschamps wrote: > Since we use recursive triggers, set recursive_triggers pragma > beforehand if not yet done. Cunning. A bit of a Rube Goldberg apparatus though, no? ___ sqlite-users mailing list

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-19 Thread Jean-Christophe Deschamps
>On Wed, May 18, 2011 at 4:10 PM, Petite Abeille > wrote: > > On May 18, 2011, at 10:50 PM, Danilo Cicerone wrote: > >> How can I simulate a > >> calendar table(maybe using the strftime funtion)? > > > > Well, you have two broad options: > > > > (1) materialize the

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Petite Abeille
On May 19, 2011, at 12:28 AM, Igor Tandetnik wrote: > That's SQLite extension. I don't believe it's legal standard SQL. The > alias in the SELECT clause acts kind of like a macro; its use in the > rest of the statement is simply replaced with the corresponding expression. Mind-boggling.

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Igor Tandetnik
On 5/18/2011 6:11 PM, Petite Abeille wrote: > In other words, how come the following works in SQLite: > > select 1 as value where value> 0; > > Or even weirder: > select 1 as value where value = 0; > > There is no from clause, there is no column 'value' per se, but nonetheless > that non

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Nico Williams
On Wed, May 18, 2011 at 5:11 PM, Petite Abeille wrote: > Where does the start_gap and end_gap come from? They are only declared in the > select part of the inner select statement, and nowhere in the from part. But > nonetheless, SQLite manages to use these non existing

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Petite Abeille
On May 18, 2011, at 11:28 PM, Igor Tandetnik wrote: > On 5/18/2011 4:17 PM, Pavel Ivanov wrote: >>> I need help to build a statement in order to select all days free from >>> events in a specific time range. >> >> This kind of task should be implemented in your application. SQL >> wasn't

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Danilo Cicerone
Amazing! Thanks a lot. 2011/5/18 Igor Tandetnik : > select startGap, min(endGap) from > ( >   select date(e1.endDate, '+1 day') startGap, date(e2.startDate, '-1 > day') endGap >   from (select startDate, endDate from events >         union all >         select '' startDate,

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Igor Tandetnik
On 5/18/2011 4:17 PM, Pavel Ivanov wrote: >> I need help to build a statement in order to select all days free from >> events in a specific time range. > > This kind of task should be implemented in your application. SQL > wasn't intended for and can't solve such tasks. Sounds like a challenge:

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Nico Williams
On Wed, May 18, 2011 at 4:10 PM, Petite Abeille wrote: > On May 18, 2011, at 10:50 PM, Danilo Cicerone wrote: >> How can I simulate a >> calendar table(maybe using the strftime funtion)? > > Well, you have two broad options: > > (1) materialize the calendar as a table >

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Danilo Cicerone
Thanks again. 2011/5/18 Petite Abeille : > > On May 18, 2011, at 10:50 PM, Danilo Cicerone wrote: > (1) materialize the calendar as a table > (2) virtualize the calendar as a generator > ___ sqlite-users mailing list

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Petite Abeille
On May 18, 2011, at 10:50 PM, Danilo Cicerone wrote: > How can I simulate a > calendar table(maybe using the strftime funtion)? Well, you have two broad options: (1) materialize the calendar as a table (2) virtualize the calendar as a generator The first option is brutal, but simple. E.g.

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Danilo Cicerone
Thanks Petite, I get it, great. Only another quick question, How can I simulate a calendar table(maybe using the strftime funtion)? Danilo 2011/5/18 Petite Abeille : > > On May 18, 2011, at 10:17 PM, Pavel Ivanov wrote: > >> SQL wasn't intended for and can't solve such

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Petite Abeille
On May 18, 2011, at 10:17 PM, Pavel Ivanov wrote: > SQL wasn't intended for and can't solve such tasks. Of course it can. Assuming a calendar and an event table: select calendar.date from calendar where calendar.date between '20110101' and '20110201' and not exists ( select 1 from event

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Pavel Ivanov
> I need help to build a statement in order to select all days free from > events in a specific time range. This kind of task should be implemented in your application. SQL wasn't intended for and can't solve such tasks. Pavel On Wed, May 18, 2011 at 4:06 PM, Danilo Cicerone

[sqlite] SQL Statement Help(selecting days).

2011-05-18 Thread Danilo Cicerone
Hi to all, I need help to build a statement in order to select all days free from events in a specific time range. E.g.: - Range(-MM-DD) from 2011-01-01 to 2011-02-01. - Event 1 from 2011-01-02 to 2011-01-08 - Event 2 from 2011-01-06 to 2011-01-12 - Event 3 from 2011-01-18 to 2011-01-21