可以吗?我有:
SELECT EventName, ClientLastName +', '+ ClientFirstName AS ClientName,
EmpLastName +', '+ EmpFirstName AS ProgSupName
FROM Employee, Salary, Events, Client, EventsScheduled, ISL, ProgramSupervisor
WHERE Events.EventNo = EventsScheduled.EventNo
AND EventsScheduled.ClientNo = Client.ClientNo
AND Client.ISLNo = ISL.ISLNo
AND Employee.EmpNo = Salary.EmpNo
AND Salary.EmpNo = ProgramSupervisor.EmpNo
AND ProgramSupervisor.EmpNo = ISL.ProgramSupervisor_EmpNo
AND Events.EventStartDate BETWEEN #11/20/2013# AND #12/30/2014#
ORDER BY ????
我想ORDER BY ProgSupName,但它会抛出错误。有什么想法吗?
答案 0 :(得分:0)
如果您想避免重复ProgSupName
的定义,一种方法是
select
*
from (
select
EventName,
ClientLastName & ", " & ClientFirstName as ClientName,
EmpLastName & ", " & EmpFirstName as ProgSupName
from
Employee em
inner join
Salary s
on em.EmpNo = s.EmpNo
inner join
ProgramSupervisor p
on s.EmpNo = p.EmpNo
inner join
ISL i
on p.EmpNo = i.ProgramSupervisor_EmpNo
inner join
Client c
on c.ISLNo = i.ISLNo
inner join
EventsScheduled es
on es.ClientNo = c.ClientNo
inner join
Events e
on e.EventNo = es.EventNo
where
e.EventStartDate between #11/20/2013# and #12/30/2014#
) as x
order by
ProgSupName