i just have this query and I want to add the ordering of its records by the result of the sum function, how to add this?
Select bus.trans_comp_id, SUM(bus.passengers*trips.cost) From bus inner join trips on bus.ID=trips.bus_id group by bus.trans_comp_id
out put of this:
trans_comp_id 1) 1:412000.00 2) 2:75000.00
I want it with desc order to have the out put:
trans_comp_id 2) 2:75000.00 1) 1:412000.00