Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have gt a SQL Query

SQL
SELECT
   [CENTRE_ID]
  , [FACULTY]
  ,SUM(CONVERT(INT ,ABS(DATEDIFF( MINUTE,CONVERT(TIME,[STARTTIME]),CONVERT(TIME,[ENDTIME]))))) AS 'TOTAL MINS PER DAY'
FROM [MISONLINE_NEW].[dbo].[BATCH_MASTER]

WHERE BATCH_STATUS LIKE 'P'
AND [STARTTIME] NOT LIKE 'ND'
GROUP BY [FACULTY], [CENTRE_ID]
, this returns all those records that matches the where clause.

Here are few records of the returned result set

CENTRE_ID    FACULTY    TOTAL MINS PER DAY
     141         2411              60
     141         2442              60
     141         2567             170
     141         2669             120




I want a fourth column that can be generated based on TOTAL MINS PER DAY that converts Minutes into hours and Minutes

CENTRE_ID	 FACULTY    TOTAL MINS PER DAY	    TOTAL HRS PER DAY
      141         2411	            60	              1hr
      141	  2442	            60	              1hr
      141	  2567	           170	              1 hr 50 mins
      141	  2669	           120	              2 hrs
Posted
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900