If you run above query then It will throw below error
Msg 8120, Level 16, State 1, Line 10
Column 'table1.o_id 39; is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
And to resolve this we need to add Group by clause like below
select o_id,sum(qty) from table1 GROUP BY o_id
Final result would be
Hope this helps , If yes then plz accept and vote the answer. Any queries / questions on this are always welcome.
Thanks & Regards
RDBurmon.Sr.Software Engineer