В большинстве баз данных вы можете просто добавить order by
:
select nVendorId, 'bank'as change_column, nRequestType as change_type,
strCreatedOn as Timestamp, nItemState as status
from vaamoz_admin.tblbankdetails
where nItemState = '1' AND nRequestType='4'
union all
select nVendorId, 'kyc' as change_column, nRequestType as change_type ,
strCreatedOn as Timestamp, nItemState as status
from vaamoz_admin.tblkycdetails
where nItemState = '1' AND nRequestType='4'
order by Timestamp;
В некоторых вам нужен подзапрос:
select t.*
from ((select nVendorId, 'bank'as change_column, nRequestType as change_type,
strCreatedOn as Timestamp, nItemState as status
from vaamoz_admin.tblbankdetails
where nItemState = '1' AND nRequestType='4'
) union all
(select nVendorId, 'kyc' as change_column, nRequestType as change_type ,
strCreatedOn as Timestamp, nItemState as status
from vaamoz_admin.tblkycdetails
where nItemState = '1' AND nRequestType='4'
)
) t
order by Timestamp;
Здесь is простой пример с использованием MySQL.