我有一个将两个选择子句与UNION结合使用的查询。我只想选择第一行。我如何使用Union来做到这一点?
Select Fault,OccurredOn From ATMStatus Where Ticket=189703 // This Will retrieve single record as the primary key is applied Union Select Fault,OccurredOn From ATMStatusHistory Where Resolved=0 AND Ticket=189703 Order By OccurredOn Desc
select top 1 * from ( Select Fault,OccurredOn From ATMStatus Where Ticket=189703 Union Select Fault,OccurredOn From ATMStatusHistory Where Resolved=0 AND Ticket=189703 ) x Order By OccurredOn Desc