troubleshooting Question

Get the Top record based on time

Avatar of Sha1395
Sha1395 asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
3 Comments2 Solutions338 ViewsLast Modified:
Hello All,

i have quite weird scenario.

Here is my table structure


No   ServiceId   MessageID   DateCreated
1    Q85M       12345       2011-08-05 10:13:05.813
2    Q85M       12346       2011-08-05 10:14:05.813
3    Q85M       12347       2011-08-05 10:15:05.813
4    Q95M       12348       2011-08-05 10:16:05.813
5    Q95M       12349       2011-08-05 10:17:05.813
6    Q95M       12343       2011-08-05 10:18:05.813
7    Q75M       12341       2011-08-05 10:18:05.813

I want to select the top(1) on service Id based on Date Created.

My query should retrun value like

3    Q85M       12347       2011-08-05 10:15:05.813
6    Q95M       12343       2011-08-05 10:18:05.813
7    Q75M       12341       2011-08-05 10:18:05.813

is this any one have any idea how can i do this,
ASKER CERTIFIED SOLUTION
Ephraim Wangoya
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros