| | |
Select max date, then max time for that date?
Please support our Oracle advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 33
Reputation:
Solved Threads: 0
Hey guys
I have a table, that lists people, with a correpsonding date and time for each activity. My structure is like:
PersonID......Date............Time
872367.........01/01/08......15:00:00
872367.........01/01/08......16:00:00
872367.........01/01/08......18:00:00
976737.........01/01/08......19:00:00
976737.........02/01/08......16:00:00
911967.........03/01/08......18:00:00
I want to have a query that returns each persons latest activity date and time, so I want a table like:
PersonID......Date............Time
872367.........01/01/08......18:00:00
976737.........02/01/08......16:00:00
911967.........03/01/08......18:00:00
I tried something like
This returned the
PersonID, latest activity date for that person, but not the latest time for that date, just the latest time for that person, if that makes sense?
So I got something like:
PersonID......Date............Time
872367.........01/01/08......18:00:00
976737.........02/01/08......19:00:00
911967.........03/01/08......18:00:00
Notice how the second row of data has the max date for that person, and the max time for that person - I need the max date for that person, and the max time for that date
Thanks for any help!
I have a table, that lists people, with a correpsonding date and time for each activity. My structure is like:
PersonID......Date............Time
872367.........01/01/08......15:00:00
872367.........01/01/08......16:00:00
872367.........01/01/08......18:00:00
976737.........01/01/08......19:00:00
976737.........02/01/08......16:00:00
911967.........03/01/08......18:00:00
I want to have a query that returns each persons latest activity date and time, so I want a table like:
PersonID......Date............Time
872367.........01/01/08......18:00:00
976737.........02/01/08......16:00:00
911967.........03/01/08......18:00:00
I tried something like
Oracle Syntax (Toggle Plain Text)
SELECT PersonID, MAX(DATE), MAX(TIME) FROM myTable GROUP BY PersonID
This returned the
PersonID, latest activity date for that person, but not the latest time for that date, just the latest time for that person, if that makes sense?
So I got something like:
PersonID......Date............Time
872367.........01/01/08......18:00:00
976737.........02/01/08......19:00:00
911967.........03/01/08......18:00:00
Notice how the second row of data has the max date for that person, and the max time for that person - I need the max date for that person, and the max time for that date
Thanks for any help!
SQL Syntax (Toggle Plain Text)
SELECT ID, DATE, TIME FROM tbl WHERE DATE =(SELECT max(DATE) FROM tbl) AND TIME= (SELECT max(TIME) FROM tbl) GROUP BY ID
?
thowwy!!!! >_<
This should work ..
+_+
sql Syntax (Toggle Plain Text)
SELECT id, date1, max(timee) FROM DATETIME GROUP BY id, date1
This should work ..
+_+
![]() |
Similar Threads
- <cfmail> question (ColdFusion)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- ASP Form error (ASP)
- assist to show the applet (Java)
- I need help covert my source code frm pic16c54a to pic16f84a (Assembly)
- Identifying Drivers needed (Windows 95 / 98 / Me)
- hover over text tips (JavaScript / DHTML / AJAX)
- generating an auto number (Visual Basic 4 / 5 / 6)
Other Threads in the Oracle Forum
- Previous Thread: helpp....correct d code
- Next Thread: What is Oracle Forms and Reports?
| Thread Tools | Search this Thread |
2009predictions acquisition amazon.com bartz bernanke cia citrix cloudcomputing crm database dell economy editor enterprise enterprise2.0 enterprisesoftware federalreserve forbes hp ibm intellipedia internet larryellison layoffs linux loughridge mediawiki michaeljackson microsoft neverland nortel notebooks oil operatingsystem oracle palm rimm saas salesforce sap seagate socialcomputing sql sun sybase technologystocks virtualiron virtualization vmware wiki wikipedia xen yahoo zoho





