Solved

SQL get latest 5 rows

Posted on 2009-04-03
2
185 Views
Last Modified: 2012-05-06
Hi Experts,
I have the following table
vessel | reportdatetime | latitude | longitude
From the table I need the latest 5 latitude and longitudes for a particular vessel. Mostly there are more then 5 rows, but it can be less or zero.

Can someone give me some assistence?
Regards, MB
0
Comment
Question by:mark_norge
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 24058032
replace vessel = 1 with your perticular value


select top 5 * from tablename
where vessel = 1
order by reportdatetime desc
0
 

Author Closing Comment

by:mark_norge
ID: 31566163
Excellent, thanks a lot!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Union 2 queries to a cte (temp table perhaps) 9 41
Sql Server group by 10 43
Connection to multiple databases 13 25
Awk & Pythagoras - applying csv file data to the problem 26 50
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question