I get this report monthly but I would like to add the departament column or type of task that is the same for projects. Can you help me? Thank
select max(tc.chargeid)"Charge ID",
max(au.first_name)"Técnico",
max(ct.description)"Descripción",
max(pd.title)"Proyecto",
max(md.title)"Fase",
max(td.title)"Tarea",
TO_CHAR((sum(ct.TIMESPENT)/1000 || ' second')::interval, 'HH24:MI:SS') "T. Empleado",
longtodate(max(ct.ts_starttime))"Código",
longtodate(max(ct.ts_starttime))"Start Time",
longtodate(max(ct.ts_endtime))"EndTime" from tasktocharge tc
left join chargestable ct on ct.chargeid=tc.chargeid
left join taskdetails td on td.taskid=tc.taskid
left join aaauser au on au.user_id=ct.technicianid
left join tasktoprojects tp on tp.taskid=td.taskid
inner join projectdetails pd on pd.projectid=tp.projectid left join milestonedetails md on md.milestoneid=tp.milestoneid LEFT JOIN SiteDefinition projectsite ON pd.SITEID=projectsite.SITEID LEFT JOIN SDOrganization projectsitename ON projectsite.SITEID=projectsitename.ORG_ID where ct.ts_endtime>= <from_lastmonth> AND ct.ts_endtime<= <to_lastmonth> and au.first_name like '%Kike%'
group by tc.chargeid order by 4,5