Вы всегда можете избежать использования select *
У меня есть похожий запрос здесь:
;with base as(
select
'Pending' as State,
a.preferredName,
cast(createDate as date) as Order_Date,
cast(birthdate as date) as Aktiv_Start_Date,
a.nationalitycode,
row_number() over (partition by a.nationalitycode order by a.nationalitycode) as p
from [app].[applicant] a
)
select *
from base
where p = 1
order by 4 desc
Установка список столбцов that I want to see
неявных в select:
;with base as(
select
'Pending' as State,
a.preferredName,
cast(createDate as date) as Order_Date,
cast(birthdate as date) as Aktiv_Start_Date,
a.nationalitycode,
row_number() over (partition by a.nationalitycode order by a.nationalitycode) as p
from [app].[applicant] a
)
select
State,
preferredName,
Order_Date,
Aktiv_Start_Date,
nationalityCode
from base
where p = 1
order by 4 desc