Home » SQL & PL/SQL » SQL & PL/SQL » select max date and Pk (oracle 11g)
select max date and Pk [message #595105] Fri, 06 September 2013 14:06 Go to next message
miroconnect@yahoo.com
Messages: 199
Registered: April 2006
Senior Member
here is my query


select 

max(PERIOD_DUE_DATE) , form_submission_id

from form_submission

group by 
form_submission_id



but this returns all the records, I need only the max date along with its form_submission_id.

In reality Its a complex query but to explain my problem I putting this simple query,

how to select max(column) and column2 from table.


[Updated on: Fri, 06 September 2013 14:08]

Report message to a moderator

Re: select max date and Pk [message #595106 is a reply to message #595105] Fri, 06 September 2013 14:13 Go to previous messageGo to next message
BlackSwan
Messages: 22905
Registered: January 2009
Senior Member
SELECT Max(period_due_date), 
       form_submission_id 
FROM   form_submission 
WHERE  period_due_date = (SELECT Max(period_due_date) 
                          FROM   form_submission) 
GROUP  BY form_submission_id 



Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: select max date and Pk [message #595107 is a reply to message #595106] Fri, 06 September 2013 14:28 Go to previous messageGo to next message
Michel Cadot
Messages: 59422
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SELECT period_due_date, form_submission_id 
FROM   form_submission 
WHERE  period_due_date = (SELECT Max(period_due_date) 
                          FROM   form_submission) 

Regards
Michel
Re: select max date and Pk [message #595108 is a reply to message #595105] Fri, 06 September 2013 14:34 Go to previous messageGo to next message
Michel Cadot
Messages: 59422
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous topics:

Michel Cadot wrote on Fri, 08 March 2013 07:28
...
For your next question remember: With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Regards
Michel


BlackSwan wrote on Tue, 14 December 2010 19:39
...
Which part of the Posting Guidelines ( http://www.orafaq.com/forum/t/88153/0/ ) did you NOT read & follow?
...


BlackSwan wrote on Thu, 17 June 2010 01:59
...
It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
...


And why don't you feedback and thank people that help you?


[Updated on: Fri, 06 September 2013 14:34]

Report message to a moderator

Re: select max date and Pk [message #595118 is a reply to message #595108] Fri, 06 September 2013 15:47 Go to previous message
miroconnect@yahoo.com
Messages: 199
Registered: April 2006
Senior Member
I am sorry, Yes it worked thx.
Previous Topic: Connect by limit issue
Next Topic: Enabling the Constraint With Enable No Validate
Goto Forum:
  


Current Time: Thu Oct 23 08:27:37 CDT 2014

Total time taken to generate the page: 0.11476 seconds