plsql: Getting another field values along with the aggregation values in a grouping statement

后端 未结 2 1991
长情又很酷
长情又很酷 2021-01-03 13:00

I am working on a time attendance system. I have the employees\' transactions stored in the following table:

2条回答
  •  孤城傲影
    2021-01-03 13:32

    You could try to use analytical(or windowing functions)

    select *
    from 
    (select id, employee_id, action_date,type,
           max(action_date) over (partition by employee_id) max_action_date,
           min(action_date) over (partition by employee_id) min_action_date
    from transaction)
    where action_date in (max_action_date, min_action_date)
    

提交回复
热议问题