DateTime colm order by Datetimestamp

Posted by Ashokn under Sql Server on 2/5/2011 | Points: 10 | Views : 1670 | Status : [Member] | Replies : 1
Hi,

Here is the reslt of below qry...

==>
Res1 121.500000 37.040000 36624.360000 January-2011
Res1 118.350000 36.080000 32611.770000 February-2011
Res1 122.800000 37.440000 10299.620000 December-2010

select DD.DamName,round(avg(Convert(decimal(18,2),DAV.WaterLevelFt)),2) 'feet',round(avg(round((Convert(decimal(18,2),DAV.WaterLevelFt))/3.28,2)),2) 'meter',
round(avg(isnull(Convert(decimal(18,2),LUT.Volume),0)),2) 'MCft',
Datename(mm,datetimestamp)+'-'+ Datename(yy,datetimestamp) as datetimestamp
from DAMSActualValues DAV
left join LookUpTable LUT on (LUT.SiteID = DAV.SiteID and LUT.WaterLevelFt = DAV.WaterLevelFt)
inner join DAMDetails DD on (DAV.siteid = DD.siteid)
where DateTimeStamp between Convert(varchar,DATEADD(year, -1,getdate()),1) and convert(varchar, getdate(),1)
and DAV.siteid=777701
group by Datename(mm,datetimestamp)+'-'+ Datename(yy,datetimestamp),DD.DamName
order by datetimestamp desc


Here I need to last colum(dateTimeStamp) in desc order so that I get result as below(latest date first):-

February-2011
January-2011
December-2010




Responses

Posted by: Prabhakar on: 2/10/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Ashokn
i think you use ORDER BY datetimestamp DESC before Write group by . it's use full for you


Best Regard's
Prabhakar

Ashokn, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response