I have an \"Observation\" table in SQL Server 2008. This table has a locationId column for a bunch of geographic locations, a few columns for observation details and a colum
select a.* from observations a inner join
(select locationid ,max(updateddate) dates from observations
group by locationid) b
on a.locationid=b.locationid
and a.updateddate=b.dates
select * from observation where date=(select max(date) from observation)
or
select top 1 * from observation order by date desc
Use the Getdate function as I used as below.
select * from TBL_MP_QC_CustomerWiseCOA_Master order by getdate() desc
Add a column to your table with a datatype of [timestamp] execute the following code:
select top(10) * from yourtablename order by columanname desc
Note:columanname should be the column you add with a timestamp type
Run query
select * from Observation
group by location
order by viewdate desc
Please also give the full details about table and what you want to get.
EDIT : Backtick removed.