November 16, 2024 at 3:13 pm
Here's my data...
I am trying to return total days in status for each status. I was suggested to use a #tempTable but I am new to that.
SELECT
[Issue ID]
,[Status Name]
,FORMAT([Status Enter Datetime], 'MM-dd-yyyy') AS 'ENTER Date'
,[No Of Seconds in Current Status] AS 'seconds in state'
,IIF([Status Exit Datetime] is null, GETDATE(), [Status Enter Datetime]) as 'EXIT Date'
,IIF([Status Exit Datetime] is null,DATEDIFF(day,[Status Enter Datetime],GETDATE()),
DATEDIFF(day,[Status Enter Datetime],[Status Exit Datetime])) AS 'DAYS IN STATUS'
INTO #tempTable
FROM my-actual-table
WHERE [Issue ID] = '7928712'
SELECT
[Issue ID]
,[Status Name]
,SUM(CONVERT( int ,'DAYS IN STATUS')) AS 'Total Days in Status'
FROM #tempTable
GROUP BY [Issue ID],[Status Name]
ORDER BY [Issue ID],[Status Name]
The query above was giving an error conversion failure.
Thanks in advance!
-joe
November 16, 2024 at 8:01 pm
It would be real helpful it you listed the datatypes for the columns you are working with and pasted what the exact error message was.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply