Re: [sqlite] tricky date time problem

2005-02-24 Thread Lloyd Thomas
Dennis, syntax error somewhere. 'group by minute union select 0, 0 where not exists (select * from event_data)' Lloyd - Original Message - From: "Dennis Cote" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Sent: Thursday, February 24, 2005 1:31 AM Subject: Re

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd, A small improvement is to limit the number of rows used to test for event existence. This avoid scanning the whole event_data table if there are many events. select minutes.i as minute, count(*) as events from (select (event_time / 60) % 60 as begin_minute, ((event_time +

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
- From: "Dennis Cote" <[EMAIL PROTECTED]> To: "sqlite-users" <sqlite-users@sqlite.org> Sent: Wednesday, February 23, 2005 8:51 PM Subject: Re: [sqlite] tricky date time problem Dennis Cote wrote: I though you wanted the minute with the most events. I

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Dennis Cote wrote: I though you wanted the minute with the most events. I added the outer select to show that that step can be done easily in the same query, rather than relying on PHP to extract this info from the full results for the hour. But of course that portion of the query doesn't work

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd Thomas wrote: Revisted your query. I was being a bit lazy. changed 'select minute, max(events)' to 'select minute, events' and added 'order by minute' to give me what I needed. Thanks Lloyd, If you want the whole table simply remove the outer select and add the order by clause as below.

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
-users" <sqlite-users@sqlite.org> Sent: Wednesday, February 23, 2005 5:41 PM Subject: Re: [sqlite] tricky date time problem Lloyd, I messed up the math for the end minute calculation. :-[ The correct query is given below. Adding 59 was intended to round the result of an integer division (whi

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
indicate where I am going wrong. Lloud - Original Message - From: "Jay" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org>; <[EMAIL PROTECTED]> Sent: Wednesday, February 23, 2005 5:39 PM Subject: Re: [sqlite] tricky date time problem --- Lloyd Thomas <[EMAI

Re: [sqlite] tricky date time problem

2005-02-23 Thread Dennis Cote
Lloyd, I messed up the math for the end minute calculation. :-[ The correct query is given below. Adding 59 was intended to round the result of an integer division (which drops the remainder), but I'm actually keeping the reminader and throwing away the quotient so it was simply wrong.

Re: [sqlite] tricky date time problem

2005-02-23 Thread Jay
--- Lloyd Thomas <[EMAIL PROTECTED]> wrote: > Thanks Jay/DRH, > this looks more promising (The "%" > operator > gives you remainder after division). Still not sure how I could apply > it to > start and end unix times. > The columns I have are :- > hour start = start

Re: [sqlite] tricky date time problem

2005-02-23 Thread Uriel_Carrasquilla
lt;sqlite-users@sqlite.org> n.plus.com> cc: Subject: Re: [sqlite] tricky date time problem 02/22/2005 06:41 PM

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
in the event_data table. Not much luck though. - Original Message - From: "D. Richard Hipp" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Sent: Wednesday, February 23, 2005 12:26 PM Subject: Re: [sqlite] tricky date time problem On Mon, 2005-02-21 at 21:49 +, Lloyd Thomas

Re: [sqlite] tricky date time problem

2005-02-23 Thread D. Richard Hipp
On Mon, 2005-02-21 at 21:49 +, Lloyd Thomas wrote: > I have a query which calculates the number of events during an hour by the > minute. It needs to work out which minute has the most events and the > average events during that hour. So it should return an array of 60 results > for an

Re: [sqlite] tricky date time problem

2005-02-23 Thread Lloyd Thomas
ion <= 1081335540 The result I get is 0|15 I was expecting 60 result rows any Ideas? Is this a version 3 operator only? - Original Message - From: "Lloyd Thomas" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Sent: Tuesday, February 22, 2005 11:41 PM Subject: Re: [sqli

Re: [sqlite] tricky date time problem

2005-02-22 Thread Lloyd Thomas
ite-users@sqlite.org> Sent: Tuesday, February 22, 2005 2:47 PM Subject: Re: [sqlite] tricky date time problem --- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > It's too bad Sqlite doesn't have the modulo operator, The "%" operator gives you remainder after division, whic

Re: [sqlite] tricky date time problem

2005-02-22 Thread Jay
--- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > > It's too bad Sqlite doesn't have the modulo operator, > > The "%" operator gives you remainder after division, > which is very close to being a modulo operator. Thanks! I went looking for the page in the documentation about expressions to

Re: [sqlite] tricky date time problem

2005-02-22 Thread Jay
that. > | > --- > How would you do that in C? > > - Original Message - > From: "Jay" <[EMAIL PROTECTED]> > To: <sqlite-users@sqlite.org>; <[EMAIL PROTECTED]> > Sent:

Re: [sqlite] tricky date time problem

2005-02-22 Thread Lloyd Thomas
try that. | --- How would you do that in C? - Original Message - From: "Jay" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org>; <[EMAIL PROTECTED]> Sent: Tuesday, February 22, 2005 2:00 AM Subje

Re: [sqlite] tricky date time problem

2005-02-21 Thread Jay
--- Lloyd Thomas <[EMAIL PROTECTED]> wrote: > I have a query which calculates the number of events during an hour > by the > minute. It needs to work out which minute has the most events and > the > average events during that hour. So it should return an array of 60 > results > for an hour

Re: [sqlite] tricky date time problem

2005-02-21 Thread Roger Binns
I have a query which calculates the number of events during an hour by the minute. It needs to work out which minute has the most events and the average events during that hour. So it should return an array of 60 results for an hour where I can use the MAX() feature in php to find the peak

Re: [sqlite] tricky date time problem

2005-02-21 Thread Lloyd Thomas
, 2005 9:49 PM Subject: [sqlite] tricky date time problem I have a query which calculates the number of events during an hour by the minute. It needs to work out which minute has the most events and the average events during that hour. So it should return an array of 60 results for an hour w

[sqlite] tricky date time problem

2005-02-21 Thread Lloyd Thomas
I have a query which calculates the number of events during an hour by the minute. It needs to work out which minute has the most events and the average events during that hour. So it should return an array of 60 results for an hour where I can use the MAX() feature in php to find the peak