Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mutlyp
Starting Member
20 Posts |
Posted - 2014-04-09 : 15:46:35
|
I have a table that holds an ID, Location and DateTime.The Datetime is in the format of yyyyMMddHHmmsec100thsecSo there would be records like this:ID Location DateTime01 Home 2014030111552200301 Home 2014030210331101001 Home 2014031108572501104 Away 2014041516332205504 Away 20140415175522053After I run the Query I want it to show:ID Location DateTime01 Home 2014031108572501104 Away 20140415175522053So it grabs the MAX Datetime of the group of IDs.What is the query to accomplish this???Please help.Thank you |
|
imex
Starting Member
1 Post |
Posted - 2014-04-09 : 17:12:23
|
Try something like this:select [ID], [Location], max([DateTime]) as [DateTime]from MyTablegroup by [ID], [Location] Hope this helps.http://www.imoveisemexposicao.com.br |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-04-10 : 04:27:07
|
Also you need to store datetime values with proper DATETIME datatype MadhivananFailing to plan is Planning to fail |
|
|
|
|
|