I am using SQL Server 2008. I have two sql queries
select Course
from StudentDB.dbo.Student
where RollNo = 130
and
select Course
from StudentDB.dbo.Courses
where Course is not null
First query will return the following value
MSc
and the second query will return
MCA
MSc
CSE
ECE
EEE
I need to join these queries and want an output like this
MSc
MCA
CSE
ECE
EEE
That is appending the result of second query to the first query and removing the duplicate value.
Please note I need result of first query on the top of the result. Here Msc is the first value because it is the result of first query. I tried union. But it returns the result of the second query itself. So union of those queries won’t helps.
I’m not a fan of DISTINCT; working from JW’s answer, this will give you the distinct list of values ordered with values from StudentDB.dbo.Student first: