How to get more columns within same alias?
(
select DateOpen AS Date,TestObjectID from RprRepair where TestObjectID = @.AssetID
union all
select DateSent ,TestObjectID from RprRepair where TestObjectID = @.AssetID
union all
select DateRepairFinished,TestObjectID from RprRepair where TestObjectID = @.AssetID
) AS Der
This works fine alone, but when i put it into union i get an error that no more than one value can be in subqueries.
Could you please explain what you are trying to do? I don't quite understand your question. What do you mena by get more columns with same alias?|||Then use join rather than correlated subquery.
select
...
, Der.* -- here you can use all the cols from Der
from ...
inner/left/right join (
select DateOpen AS Date,TestObjectID from RprRepair where TestObjectID = @.AssetID
union all
select DateSent ,TestObjectID from RprRepair where TestObjectID = @.AssetID
union all
select DateRepairFinished,TestObjectID from RprRepair where TestObjectID = @.AssetID
) AS Der on <conditions>
No comments:
Post a Comment