Avatar of jl66
jl66
Flag for United States of America asked on

Request a query to compare timestamp

Have a table T with the columns/records
GROUP    NAME    T1         T2
2             BB        7/1/11    7/3/11
2             SS        7/5/11    7/6/11
3             SS        7/1/11    7/3/11
3             CC        7/5/11    7/6/11
3             DD        7/4/11    7/6/11
4             SS        8/1/11    8/2/11
4             SS        8/3/11    8/3/11
....
Select the records in each group like 2, 3,... if Name =SS and T1 > T2 (here T2 comes from any other record in the same group). For example,

2       SS        7/5/11    7/6/11   -- selected because its T1=7/5/11 > T2=7/3/11 (other record in the same group)

However, none of records are selected from group =3.

Similarly, the following record is selected
4       SS        8/3/11    8/3/11

I tried to use " over partition by ...". Just missed something.  I will greatly appreciate any guru's advice/queries.
Oracle DatabaseSQL

Avatar of undefined
Last Comment
Sean Stuber

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
paquicuba

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Sean Stuber

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jl66

ASKER
Thank both of you very much. Excellent!!
sdstuber: your answer just missed a bit, which rarely happened.
Sean Stuber

hmmm, I guess I misunderstood the question then.   I tested my query and it did exactly what I thought you asked for.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy