Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting the value of a column based on the max value of another column in a group

Jason SmithJul 15 2015 — edited Jul 15 2015

Please let me know if there is a simple way to do this.  I've come up with a way, but it is terribly inefficient and this needs to run quick.

  GROUP_ID REGISTER_ID READ_VALUE TIMEST                     

---------- ----------- ---------- -----------------------------

         2           1      0.035 01/01/2015 00:00:00.000000000

         2                  0.035                              

         3           1       1.11 07/14/2015 14:50:32.943000000

         3           2        222 01/01/0001 13:36:47.017436000

         3                 223.11                             

So what I need is for everywhere REGISTER_ID is NULL, I need the value of TIMEST to be the TIMEST of the MAX(READ_VALUE) for that GROUP_ID (not including the rows where REGISTER_ID is NULL).  So the result would look like this:


  GROUP_ID REGISTER_ID READ_VALUE TIMEST                     

---------- ----------- ---------- -----------------------------

         2           1      0.035 01/01/2015 00:00:00.000000000

         2                  0.035 01/01/2015 00:00:00.000000000                             

         3           1       1.11 07/14/2015 14:50:32.943000000

         3           2        222 01/01/0001 13:36:47.017436000

         3                 223.11 01/01/0001 13:36:47.017436000                            

Anyone have any thoughts?

This post has been answered by Hoek on Jul 15 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2015
Added on Jul 15 2015
5 comments
253 views