My query
SELECT TOP 1 *, COUNT(*) AS totalRun
FROM history
ORDER BY starttime DESC`
Estimated outcome is all the data from 1 row in the history table with the latest starttime and a fieldtotalrun with the total amount of records, but... I get the following error.
Msg 8120, Level 16, State 1, Line 1
Column 'history.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
What am I doing wrong?
EDIT
example of the result:
These are all the fields of the row with the latest starttime in the history table with the extra COUNT field 'totalRun'
group byclause. - Ravi Singh