sql server - Average of Most Recent 100 SQL Database Entries -
select dc_grp.dc_grp, dc_grpx.reqt_id, avg(results.[var]) average, stdev(results.[var]) stddev results inner join...
currently pulling of var fields out of results, need recent 100. how can call recent 100 within avg( ) call?
assuming have column define recent, can subquery:
select dc_grp.dc_grp, dc_grpx.reqt_id, avg(r.[var]) average, stdev(r.[var]) stddev (select top 100 * results order createdat desc) r inner join...
this example assumes name of column createdat
.
Comments
Post a Comment