Oracle query and aggregate function

前端 未结 2 1100
余生分开走
余生分开走 2021-01-26 11:31

I have table name employee_1 suppose in oracle. If the mobile_no and sim_no is same i want select maximum start_date. I have tried , but no success. Please help The employee_1 t

2条回答
  •  鱼传尺愫
    2021-01-26 12:08

    NOTE: Your definition, example data and expected result are not consistent. See that you include in the result the line:

    1111111111  1111111112  11/10/2017 21:02:44 13/10/2017 21:02:44
    

    where the Mobile and SIM numbers are different.

    Still, try this:

    EDIT: TOP 1 was replaced with LIMIT 1 (Oracle).

    SELECT LIMIT 1 Mobine_No , Sim_No , Start_Date , End_Date
      FROM YourTable
     WHERE Mobine_No = Sim_No 
    ORDER BY Start_Date DESC ;
    

    Alternative:

    SELECT Mobine_No , Sim_No , MAX(Start_Date) , End_Date
      FROM YourTable
    

提交回复
热议问题