my table this is the result I want to display john — total paid shoes and bag dave <– total of bag,’shoes is unpaid so 1000 is not added to total’ this is my controller it gives me an error the total is same in all name Answer You could look to join sub queries, that certainly would be one