SELECT "Tickets"."Request Id", "Accounts"."Account Name" as "Account Name",CONCAT('Tkt# ', "Tickets"."Request Id", ': ', "Tickets"."Subject") as "Ticket Details", "Tickets"."Status" as "Status",
DATE("Tickets"."Created Time") as "Ticket Created Dt", MAX(DATE("Time Entry"."Created Time")) as "Last Time Entry Dt", sum(round("Time Entry"."Seconds Spent"/60/60,2)) as "Hours Entered"
from "Time Entry"
JOIN "Tickets" ON "Tickets"."ID" = "Time Entry"."Request"
JOIN "Agent" ON "Time Entry"."Agent" = "Agent"."ID"
JOIN "Contacts"ON "Tickets"."Contact ID" = "Contacts"."ID"
JOIN "Accounts" ON "Contacts"."Account ID" = "Accounts"."ID"
where
DATE("Time Entry"."Created Time")
BETWEEN start_day(month,previous_nmonth(current_date(),1)) AND end_day(month,previous_nmonth(current_date(),1))
GROUP BY "Tickets"."Request Id", "Ticket Details", DATE("Tickets"."Created Time"), "Accounts"."Account Name","Tickets"."Status"
ORDER BY "Tickets"."Request Id" ASC
Writer is a powerful online word processor, designed for collaborative work.