以下は私の質問です
Select vehicleID from trip where (StartingDate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'')
or (enddate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'')
or(StartingDate <= @StartDate and enddate >= @EndDate)
UNION
Select vehicleID from VehicleMaintenance where (FromDate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'')
or (todate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'')
or (FromDate <= @StartDate and todate >= @EndDate)
) as vehicle
上記のクエリ結果から個別のVehicleIdを選択する方法...