select
a.aCol,
b.bCol
from a inner join b on a.id = b.id
union
select
a.acol,
c.bcol
form a inner join c on a.id = c.id
order by b.bCol
a.aCol,
b.bCol
from a inner join b on a.id = b.id
union
select
a.acol,
c.bcol
form a inner join c on a.id = c.id
order by b.bCol
The known interpreter change gives a semi-cryptic error of "The multi-part identifier "tblPrefix.columnName" could not be bound." This basically means that in the order by b.bCol doesn't exists in both union queries. Therefore, the order by needs to drop the "b." becoming "bCol".
Solution:
select
a.aCol,
b.bCol
from a inner join b on a.id = b.id
union
select
a.acol,
c.bcol
form a inner join c on a.id = c.id
order by b.bCol
a.aCol,
b.bCol
from a inner join b on a.id = b.id
union
select
a.acol,
c.bcol
form a inner join c on a.id = c.id
order by b.bCol
0 comments:
Post a Comment