[SQL] How to find number of seconds between 2 timestamps

2009-02-17 Thread Woody Woodring
I am trying to calculate a rate per second and am having trouble getting the number of seconds between the two timestamps to use in the formula. overview=> select extract(epoch from interval '1 day'::interval); date_part --- 86400 (1 row) overview=> select extract(epoch from inter

[SQL] Insert with pl/pgsql trigger

2008-05-07 Thread Woody Woodring
I am trying to create a table that is a log of another table in 8.3.1 using a trigger. Both tables look like Table "public.cpe_health_history" Column|Type| Modifiers --++--- cpe_healthid | integer| not null mac | macaddr| po

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread Woody Woodring
I came into this thread late, so I don't know what you schema looks like. I have a table that has a timestamp with time zone field and other data. I can write a query that give me a count per day SELECT count(*) AS count, date_trunc( 'day', hour) AS day FROM hist_callhealth GROUP BY day; Thi