Sql Query with inner select [duplicate]
问题 This question already has answers here : Sql query to create a calculated field (2 answers) Closed 5 years ago . I have this sql query: SELECT DISTINCT [Card NO], [User Name], ( SELECT MIN(DateTime) AS [Enter Time], MAX(DateTime) AS [Exit Time], MAX(DateTime) - MIN(DateTime) AS [Inside Hours] FROM ExcelData ) FROM ExcelData GROUP BY [Card NO], [User Name], DateTime Table Schema: CardNO | UserName | DateTime I tried to execute it but with no success. I says that it is an invalid query. Can