假设我有这个代码:
DECLARE @IncludeDuplicateAddressIDs tinyint
-- Value of @IncludeDuplicateAddressIDs set here ! --
IF(@IncludeDuplicateAddressIDs = 1)
SELECT AddressIds FROM RTS.ADDRESSES
ELSE
SELECT DISTINCT(AddressIds) FROM RTS.ADDRESSES
我可以将这两个SELECT
语句合二为一吗?也就是说,只使用一个SELECT
,我要么显示所有 AddressID,要么只显示一个?