Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Location
    18 Sur 3917
    Posts
    17

    Unanswered: select the last row under a condition

    Hi, I want a make a query, to do a select the last row, only one under a condition of the one date.

    For example:

    select e.num_expediente || ' ' || e.nombre || ' ' || e.apellido_paterno || ' ' || e.apellido_materno from rh_empleado e, rh_empleado_hist eh, rh_emp_plaza ep where ep.emp_id=e.emp_id and e.emp_id=eh.emp_id

    this query returns me several values. I need something like:

    select e.num_expediente || ' ' || e.nombre || ' ' || e.apellido_paterno || ' ' || e.apellido_materno from rh_empleado e, rh_empleado_hist eh, rh_emp_plaza ep where ep.emp_id=e.emp_id and e.emp_id=eh.emp_id
    and eph.asig_date = MAX(eph.asig_date)

    I hope some peaple can help me.

    Regards...

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Will this work?
    Code:
    select e.num_expediente || ' ' || e.nombre || ' ' || e.apellido_paterno || ' ' || e.apellido_materno from rh_empleado e, rh_empleado_hist eh, rh_emp_plaza ep where ep.emp_id=e.emp_id and e.emp_id=eh.emp_id
    and eph.asig_date = (select MAX(eph.asig_date) from ... where ...)

  3. #3
    Join Date
    Jul 2003
    Posts
    2,296
    what table does "MAX(eph.asig_date)" come from?
    also, how does it map to your other 3 tables?
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  4. #4
    Join Date
    Mar 2003
    Location
    18 Sur 3917
    Posts
    17
    thanks very much, that was helpful

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •