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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-05-18 : 08:37:48
|
Jake writes "Hi all
Please help me as I am stuck on this query.
I have a query resulted from joining four tables and the returned result has over 900 records, however most are duplicate for some group of items except for the Date field called "Last_Service_Date".
I would like to get back the items that have most recent Date in "Last_Service_Date", this would reduce the result to about 50 rows. But I have no Idea how.
I have tried using the "DATEDIFF(day, Last_Service_Date, getdate()) AS no_of_days" so I could use the MIN function to achieve the result but still no luck.
I get all sort of error with regards to Group By and Aggregate function when using MIN
There must be a way using the SELECT statment as I don't want to have to loop through the result set row by row to get out the most recent date.
Much appreciated for any help
Jake" |
|
|
|
|
|