Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL report to display total time for current month in hours

$
0
0

We currently have the following SQL report setup to show us the total amount of hours spent on support tickets, per client (which is categorised by a company filed) which is displayed in minutes. The reason we show it in minutes is because we do not know how to show hours with a decimal point to show .25, .50, .75 for example.

Does anyone know how we can run a SQL report that will show the result in hours including a decimal point?

SELECT c_company AS 'Company',
SUM (tw.time_spent)/60
AS "Time Worked in Minutes"

FROM tickets t LEFT OUTER JOIN ticket_work tw ON tw.ticket_id = t.id

--the next line should pull anything from the beginning of the month onward
WHERE tw.created_at >= DATE('now','start of month')

--the next line should limit the date range to stop at the end of the current month
AND tw.created_at <= DATE('now','start of month', '+1 month')

GROUP BY Company



Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>