I am trying to figure out an SQL query to get aggregate calculations from a data table. The data table is a simple list of dates and data (real). I am simply trying to get the AVG, MAX, and MIN of the top 100 data points in descending order. There are several thousand data points in the table. The Select statement I have used that does not work is:
SELECT TOP 100 Cur_Date, AVG(DataMean) AS DMEAN, MAX(DataMean) AS DMAX, MIN(DataMean) AS DMIN FROM DataTable WHERE PartNumber = ? ORDER BY Cur_Date DESC.
Can anyone help?