Do you really need to do this in T-SQL? This is usually made in the front end.
If it's completely needed on T-SQL, you might need to union the detail with a query with subtotals adding a (non-visible) column to order the results so the subtotal will come after (or before if needed) the detail.
For a coded response, follow Keith's advice.