Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle select stmt

Posted on 2014-09-05
1
Medium Priority
?
388 Views
Last Modified: 2014-09-05
Greeting,

I have field1,field2 and field3 in tbl1. field3 is a date/time field with the following sample data.
I want to select the record which has the max(field3) and group by field1. Please suggest.

Field1    Field2   Field3
100        300       1-SEP-14
100        400       3-SEP-14
0
Comment
Question by:mrong
1 Comment
 
LVL 32

Accepted Solution

by:
awking00 earned 2000 total points
ID: 40305800
select field1, field2, field3 from
(select field1, field2, field3,
 row_number() over (partition by field1 order by field3 desc) rn
 from yourtable)
where rn = 1;
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to recover a database from a user managed backup
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question