Subject | SQL Help please: Group by with a text blob |
---|---|
Author | OB1 |
Post date | 2008-06-27T12:11:58Z |
I've been using a normal select with no joins, then I needed to pull in
another value MAX(.....). The problem is that I'm selecting a text blob
which cannot go in the 'Group by', Is there a way to rewrite the SQL below
so that I can still pull in the MAX col and also the Text blob?
SELECT t.TASK_ID, t.TITLE, t.DESCRIPTION <lots of other t. fields here>
, MAX(th.change_id) as LastViewChangeID
from TASKS t
left outer join TASKS_HISTORY th
on t.TASK_ID = th.TASK_ID and th.CHANGE_TYPE = 'V' and
th.created_by_ID=:USER_ID
WHERE t.ASSIGNED_TO_ID=:USER_ID
group by t.TASK_ID, t.TITLE, t.DESCRIPTION <other t. fields>
[Non-text portions of this message have been removed]
another value MAX(.....). The problem is that I'm selecting a text blob
which cannot go in the 'Group by', Is there a way to rewrite the SQL below
so that I can still pull in the MAX col and also the Text blob?
SELECT t.TASK_ID, t.TITLE, t.DESCRIPTION <lots of other t. fields here>
, MAX(th.change_id) as LastViewChangeID
from TASKS t
left outer join TASKS_HISTORY th
on t.TASK_ID = th.TASK_ID and th.CHANGE_TYPE = 'V' and
th.created_by_ID=:USER_ID
WHERE t.ASSIGNED_TO_ID=:USER_ID
group by t.TASK_ID, t.TITLE, t.DESCRIPTION <other t. fields>
[Non-text portions of this message have been removed]