I have an issue, we have trac postgresql db (version 8.4) and we need to get the worklog based on the tags(keywords) in tickets and group time spent on these tickets.
This is my query:
select round(sum(wl.endtime-wl.starttime)/3600.0, 2) AS sum_of_hours,
string_to_array(t.keywords, ',') AS keywords
from work_log AS wl
JOIN ticket AS t ON t.id = wl.ticket
where t.keywords SIMILAR TO '%SWA.IMPLEMENTATION%'
GROUP BY t.keywords
HAVING string_to_array(t.keywords, ',') @> ARRAY['SWA.IMPLEMENTATION'];
The output is:
sum_of_hours | keywords
--------------+------------------------------
950.08 | {Running,SWA.IMPLEMENTATION}
11.00 | {SWA.IMPLEMENTATION,Done}
341.63 | {SWA.IMPLEMENTATION}
49.25 | {SWA.IMPLEMENTATION,Running}
(4 rows)
My goal is to group all hours where "SWA.IMPLEMENTATION" is presented. So all those 4 lines should be group together.
Thanks for any advice.