select e2.SortName,sum(e1.NormalAmount) as Amount from xfront_hismx e1
left join sys_endPsort e2 on e1.SortCode=e2.SortCode
left join Xfront_liushui_info_his e3 on e3.SerialNumber=e1.SerialNumber
right join Xfront_cyCheckout e4 on e4.CheckOutNo=e3.BillNo
where e2.SortName='助浴类' and e1.ReserveCosno=0 and e1.TransferoutCoSno=0 and e1.TuiDanCoSno=0 and
Convert(varchar(100),e4.CheckTime,23)=CONVERT(varchar(100), '2015-05-31', 23) and e1.CheckOutCoSno=e3.sno group by e2.SortName