I have this table from fingerprint sensor and I need to show the result in one row
ID | DateTime | Flag -------------------------------------
Alternatively you could use PIVOT, which has been developed specifically to turn ROWS into COLUMNS.
PIVOT
ROWS
COLUMNS
SELECT id , [I] as [IN-DateTime] , [O] as [OUT-DateTime] FROM Table t PIVOT (max(dateTime) for flag in ([I], [O])) as pvt;