Home » SQL & PL/SQL » SQL & PL/SQL » How i can retrieve the last booking time (SQL*Plus: Release 10.1.0.4.2, win XP)
How i can retrieve the last booking time [message #348014] Mon, 15 September 2008 07:08 Go to next message
ghssal
Messages: 5
Registered: September 2008
Junior Member
How i can retrieve the last booking time for one ID from many different ID how have a similar booking time.
Re: How i can retrieve the last booking time [message #348020 is a reply to message #348014] Mon, 15 September 2008 07:14 Go to previous messageGo to next message
Michel Cadot
Messages: 64145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you have a timestamp, yes.

Regards
Michel
Re: How i can retrieve the last booking time [message #348038 is a reply to message #348020] Mon, 15 September 2008 08:22 Go to previous messageGo to next message
ghssal
Messages: 5
Registered: September 2008
Junior Member
any ideas?
thanks!!
Re: How i can retrieve the last booking time [message #348043 is a reply to message #348038] Mon, 15 September 2008 08:33 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Use MAX function.
Re: How i can retrieve the last booking time [message #348044 is a reply to message #348020] Mon, 15 September 2008 08:34 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
Anything unclear to you in the below answer which Michel gave?

Michel Cadot wrote on Mon, 15 September 2008 17:44
If you have a timestamp, yes.

Regards
Michel



Post a test case with the queries you have tried.

Regards,
Jo
Re: How i can retrieve the last booking time [message #348060 is a reply to message #348014] Mon, 15 September 2008 09:03 Go to previous messageGo to next message
ghssal
Messages: 5
Registered: September 2008
Junior Member
I have alredy used MAX function, but i get too all the other ID which share with the same booking time.
I want only the data for the in this particular ID.
any ideas?
thanks
Re: How i can retrieve the last booking time [message #348063 is a reply to message #348060] Mon, 15 September 2008 09:07 Go to previous messageGo to next message
Michel Cadot
Messages: 64145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
any ideas?

Yes, post the decription of your table and explain what you want from the columns.

By the way, MAX can be associated with "group by" and "having" to partition by something and restrict the result to some groups.

Regards
Michel
Re: How i can retrieve the last booking time [message #348112 is a reply to message #348014] Mon, 15 September 2008 12:19 Go to previous messageGo to next message
kvignes1
Messages: 33
Registered: September 2007
Member

select max(<timestamp column>) from table
where ID=<'Particular ID'>;

Still unclear? Paste the query you are using we will get it right
Re: How i can retrieve the last booking time [message #348344 is a reply to message #348014] Tue, 16 September 2008 08:20 Go to previous messageGo to next message
ghssal
Messages: 5
Registered: September 2008
Junior Member
select ID,udate
from T1, (
select distinct(ID) AS B, MAX(udate) AS S
from T1
GROUP BY ID)
where 19612 = B and udate = S ;

the query
ID uDATe
------ ----------
1910 20080812
1911 20080812
1912 20080812
1913 20080812
1914 20080812


But i need only
1912 20080812

Re: How i can retrieve the last booking time [message #348353 is a reply to message #348344] Tue, 16 September 2008 08:53 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Quote:

But i need only
1912 20080812



What rule determines this?

Why do you want the 1912 line, and not the 1911 or 1913 line?

Also read the guidelines on how to post and follow them.
Re: How I can retrieve the last booking time [message #348406 is a reply to message #348014] Tue, 16 September 2008 11:46 Go to previous messageGo to next message
ghssal
Messages: 5
Registered: September 2008
Junior Member
I selected one ID, for example 1912, to add new information, it could just as well have been 1920 or any other ID. I need to be able to select only one ID among those registered the same day and have the same udate.

Re: How I can retrieve the last booking time [message #348419 is a reply to message #348406] Tue, 16 September 2008 12:31 Go to previous message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Once again:

Define a rule for which one you want.

Plus, you faked your output, and you cannot use 1920 as that isn't even in the output, but since it was fakes, I guess you can Wink
Previous Topic: Real-time concurrency problems
Next Topic: Value of variable after SELECT INTO returns > 1 row
Goto Forum:
  


Current Time: Fri Dec 09 11:37:27 CST 2016

Total time taken to generate the page: 0.11087 seconds