我目前在excel中使用sql查询,因此用户可以通过刷新工作表来获得结果。
结果将显示,但根据我的查询,列的顺序与它们应该的顺序不同
在数据选项卡中的excel中,我从其他来源中选择并从sql server中选择然后我连接到我的数据库。我得到一个输入我的sql命令(查询)的选项,它运行得很好。但是列的顺序与查询中指定的顺序不同。
select p.first_name + ' ' + p.last_name as Name, CONVERT(CHAR(10), dob, 101) AS DOB, st.id_no AS ID, addr.address, e.program_name as Program_Name
--case when end_date is null then 'Y' else 'N' end as 'Enrolled?'
from programenrollment e With (NoLock)
join people p on e.people = p.people
left outer join service_track st WITH(NOLOCK) ON p.people = st.people
left outer join person_address addr on st.people = addr.people
where e.is_deleted = 0
and((end_date is null) or (end_date >= GETDATE()))
and e.people is not null
and program_name in (
'Physical Education',
'Music'
)
order by name, e.program_name--, st.id_no
结果在Microsoft sql server Management studio中:
NAME, DOB, ID, ADDRESS, PROGRAM_NAME
结果excel
PROGRAM_NAME, ID, ADDRESS, DOB,NAME
结果在sql server management studion中
我已经尝试过重写但我得到了相同的结果。这可以在周围工作吗?