[SQL] extract some column/value pairs via hstore

2011-06-13 Thread Tarlika Elisabeth Schmitz
In a PL/pgSQL function, I need to extract column/value pairs from a table ignoring some of the columns. The excluded column names have previously been stored in an array "ak", which contains array['country_fk', 'region_fk', 'id'] SELECT key, value FROM ( SELECT (each(hstore(town))).* FROM to

Re: [SQL] selecting records X minutes apart

2011-06-13 Thread Gavin Flower
How about this (that does not require special functions nor triggers: DROP TABLE IF EXISTS val; CREATE TABLE val ( id int, ts timestamp ); INSERT INTO val VALUES (0, '1-Jan-2010 20:00'), (1, '1-Jan-2010 20:03'), (1, '1-Jan-2010 20:04'), (0, '1-Jan-2010 20:05'),