It is great feature where can when can be used in order by clause in sql server , below is the query where at the time of creation record modified date will be null and creation date will be present date time, but at the time of update modified date will be updated, now using order by clause and case when ,
SELECT [incident_IncidentId]
,[incident_CaseNum]
,[incident_CreatedDate]
,[incident_ModifiedDate]
,[incident_StatusId]
,[incident_NoOfVictim]
,[incident_Note]
FROM [PCCAS].[dbo].[incident] a
ORDER BY
CASE WHEN a.incident_ModifiedDate IS NULL THEN a.incident_CreatedDate
ELSE a.incident_ModifiedDate END DESC
Now, datawill come based on case when
No Responses