I want to calculate the aggregate function and display records from 2 tables.
here is the code
select b.bus_id ,sum(CAST(b.fare as int) ) total,bm.bus_name from Busdetails b,BusMaster bm where datename(MONTH,b.tour_date)='august' and b.bus_id=bm.bus_id group by b.bus_id
but showing below error
Msg 8120, Level 16, State 1, Line 19
Column 'BusMaster.bus_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
how to solve this