Re: [SQL] Use select and update together

2011-09-13 Thread Samuel Gendler
On Mon, Sep 12, 2011 at 3:36 AM, Boris wrote: > > SELECT ( > UPDATE tbl SET val = 1 > WHERE KEY = any('{0,1,2,3,4,5}'::int[]) > returning key > ); > > cause syntax error. Is any query of such type (update warped into > select) is possible? > > Just lose the select ();

[SQL] Partition over a sliding date window

2011-09-13 Thread Guillaume Roger
Hi, I have a simple table with 3 fields: date, value and username, which can hold identical rows. What I am trying to do is to have for each date the count of distinct username for the 30 previous days. I was hoping to get this with a partition, as in the following non-working exemple SE

[SQL] Window function sort order help

2011-09-13 Thread Dianna Harter
Having trouble getting a window function to sort correctly. Given this data consumer_id | move_date | history_timestamp -++ 12345| 2008-01-05 | 2007-12-11 06:02:26.842171 12345| 2008-02-29 | 2008-02-05 07:22:38.04067 12