在Access 2010中按重命名字段排序?

时间:2013-11-17 00:53:34

标签: sql sql-order-by ms-access-2010

可以吗?我有:

    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,但它会抛出错误。有什么想法吗?

1 个答案:

答案 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