sql - Getting the latest record by DATETIME or NULL -
I have the following questions: If I am getting the following results: I know I am doing this wrong, but what I want is the record with the latest date. If the timestamp is empty then I want that record instead. In the end I do not want to record only 1. Thank you!
DISTINCT c.id, select creator, ls . Name, ld.timestampOut countermeasures c Left Join external ld.documentId = c.id Left external lifecycleDetails ls.id = ld.lifecycleStatus where ld.timestampOut = on ld (Select Max (lifecycleDetails from timestampOut)) or ld lifecycleState ls Join .timestampOut is NULL
If you are using SQL Server, you can use ROW_NUMBER ()
for this purpose:
select ID, manufacturer name, select timestampOut (c.id, manufacturer, ls.name, ld.timestampOut, ROW_NUMBER ( ) over the counter c combination based on ld as the Left external SEQNUM lifecycleDetails ld (ID then split (the case when ld.timestampOut null command 1 and 2 at the end), timestampOut desc) .documentId = c.id, Add life cycle to the left OUTER ls.id = ld at ls. LifecycleStatus) T WHERE seqnum = 1;
Comments
Post a Comment