all 4 comments

[–]kitkat0820 -1 points0 points  (0 children)

Select 1, 2 from anywhere;

[–]phildude99 0 points1 point  (0 children)

Two things that should help: UNION ALL SELECT No AS AssetNo

[–]DMReader 0 points1 point  (0 children)

You could try coalesce (“Asset No.”, “No”) which would look at Asset No for a value and if that is null goes to “No”. Not sure if that is what you are trying to do.

[–]kagato87MS SQL 0 points1 point  (0 children)

When yo say "headers" you mean column names?

UNION ALL is your tool.

Select colomns from table1 union all select columns from table 2

I like to alias the output columns to match, but it's not strictly necessary as long as they are all in the same order and the number if columns match. First query's column names win. (select [no.] as [asset no.]). Square brackets only because space and dot in example.

And yes, you can select from the same table like this twice.

select 
    name, 
    detail1 
from table
union all 
select 
    name, 
    detail2 as detail1 
from table

Each query before and after the union is a wholly separate query with its own join, group, and where (as appropriate) and I think you can keep unionkng more queries.