I've created a query to get the values from the table's columns which are not null through this query:
Select * from(
SELECT OEID, Chest_Pain as Head, Chest_PainComment as Detail
FROM tblComplaints
union
SELECT OEID, SOB as Head, SOBComment as Detail
FROM tblComplaints
union
SELECT OEID, PND as Head, Cyanosis as Detail FROM tblComplaints
union
SELECT OEID, Odema_Feet as Head, Vertigo + as Detail From tblComplaints
union
SELECT OEID, DM as Head, DMComment as Detail
FROM tblComplaints
union
SELECT OEID, RS as Head, RSComment as Detail
FROM tblComplaints
) as t
where (Head is not null and ltrim(rtrim(Head)) <> '')
and OEID = 6012
And the data is coming up fine but the problem is that this query automatically doing A to Z sort in the output result. What I need to do is to get the result by the sort of how I entered each line.
For-Example: Currently I am getting the output of this query as below:
Head Detail
Chest_Pain Chest_PainComment
DM DmComment
Odema_Feet Vertigo
PND Cyanosis
RS RSComment
And I want it to be like this:
Head Detail
Chest_Pain Chest_PainComment
RS RSComment
PND Cyanosis
DM DMComment
The bottom line is there should not be A to Z sort, that is happening in my query. I don't know why this A to Z sorting is happening in the query while I've not sorted it anywhere.
I will appreciate the help.