How to select the distinct row if the particular column have same record multiple times in sql server 2008 and order by datetime.
I have following column in table:
- id
- username
- fileid
- datetime
I have try using following sql:
SELECT DISTINCT(fileid) FROM [DatabaseName].[dbo].[TableName] where usernumber = '015578957'
How can I select other column in above sql and order by datetime column and also return result set row where fileid column is distinct.
If you want to select first distinct record use MIN as in above query and if you want to retrieve the last one use MAX instead of MIN.