Skip to content
Advertisement

Selecting the union part of an sql query

I have this query

I put this as a common table expression, how do I select R.SoldDate in that case?

Specifically I am trying to run this

But I cannot select Inactives.SoldDate

Advertisement

Answer

I think what you are after here is a computed column, something like this:

The computed column Type keeps track of the origin of each record, so that you will know this after the union has been peformed. Note that I switched to UNION ALL, assuming that you always wanted to retain all records.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement