SELECT MAX(employeelist.姓名) AS 姓名,
sum(case out.typeid when 7 then 金额 else 0 end) as 现金,
sum(case out.typeid when 8 then 金额 else 0 end) as 挂帐,
sum(out.金额) AS 合计
FROM out LEFT OUTER JOIN
employeelist ON out.employeeid = employeelist.id
WHERE (out.日期 >= '2008-07-01') AND (out.删除 = 0) AND (out.deparid = 7)
GROUP BY out.employeeid
sum(case out.typeid when 7 then 金额 else 0 end) as 现金,
sum(case out.typeid when 8 then 金额 else 0 end) as 挂帐,
sum(out.金额) AS 合计
FROM out LEFT OUTER JOIN
employeelist ON out.employeeid = employeelist.id
WHERE (out.日期 >= '2008-07-01') AND (out.删除 = 0) AND (out.deparid = 7)
GROUP BY out.employeeid