[storm] How to express DISTINCT ON for PostgreSQL.

Gavin Panella gavin.panella at canonical.com
Fri Sep 17 11:38:13 BST 2010


Hi,

How can I express the following query with Storm:

  SELECT DISTINCT ON (assignee) task.* FROM task
   ORDER BY assignee, date_created

(Get the oldest task for each assignee.)

I can do something like:

  columns = SQL("DISTINCT ON (assignee) assignee"), Task
  ordering = Task.assignee, Task.date_created
  results = store.find(columns).order_by(ordering)

However, list(results) comes out with something like:

  [(1, <Task object at ...>),
   (2, <Task object at ...>)]

I'd like to be able to not select the assignee column separately, and
I'd like to avoid using SQL() if possible.

Thanks, Gavin.



More information about the storm mailing list