Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to get this result in oracle database?

How to get this result in oracle database?

Scheduled Pinned Locked Moved Database
databaseoracletutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HowardCheng
    wrote on last edited by
    #1

    I don't know how to write this PL/SQL in oracle, thanks for your advice.
    Because the amount of data in the table is large, it is not suitable to find the max PDate and then compare it from the source table.

    Table data:
    Process PDate Status
    100 2022/05/21 19:58:03 0
    100 2022/05/22 07:01:00 0
    100 2022/05/22 13:01:10 1
    101 2022/05/22 08:23:39 0
    101 2022/05/22 10:17:39 0
    101 2022/05/22 17:49:39 1
    102 2022/05/22 13:14:48 0

    Requirement: Get the status of the last record of different processes on 2022/05/22
    Select result:
    Process PDate Status
    100 2022/05/22 13:01:10 1
    101 2022/05/22 17:49:39 1
    102 2022/05/22 13:14:48 0

    M 1 Reply Last reply
    0
    • H HowardCheng

      I don't know how to write this PL/SQL in oracle, thanks for your advice.
      Because the amount of data in the table is large, it is not suitable to find the max PDate and then compare it from the source table.

      Table data:
      Process PDate Status
      100 2022/05/21 19:58:03 0
      100 2022/05/22 07:01:00 0
      100 2022/05/22 13:01:10 1
      101 2022/05/22 08:23:39 0
      101 2022/05/22 10:17:39 0
      101 2022/05/22 17:49:39 1
      102 2022/05/22 13:14:48 0

      Requirement: Get the status of the last record of different processes on 2022/05/22
      Select result:
      Process PDate Status
      100 2022/05/22 13:01:10 1
      101 2022/05/22 17:49:39 1
      102 2022/05/22 13:14:48 0

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      First filter by PDate = datevariable, order by PDate Descending. Select the top 1 record.

      Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups