select a.EatCode,a.unit,a.Eatprice,d.code,a.eatname,sum(a.eatnums) as eatnums,sum(a.eatgs) as eatgs,
sum(a.eatmoney) as eatmoney,d.name as SecTypeName,a.zs as sm from v_sorderdishes a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.eatprice,d.name,a.zs
union all select a.eatcode,a.unit,(a.price) as eatprice,d.code,a.eatname,sum(a.nums) as eatnums,sum(a.gs) as eatgs,
sum(a.nums*a.price) as eatmoney,d.name as sectypename,a.tmp10 as zs from v_sorderparty a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.price,d.name,a.tmp10 order by a.eatcode
sum(a.eatmoney) as eatmoney,d.name as SecTypeName,a.zs as sm from v_sorderdishes a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.eatprice,d.name,a.zs
union all select a.eatcode,a.unit,(a.price) as eatprice,d.code,a.eatname,sum(a.nums) as eatnums,sum(a.gs) as eatgs,
sum(a.nums*a.price) as eatmoney,d.name as sectypename,a.tmp10 as zs from v_sorderparty a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.price,d.name,a.tmp10 order by a.eatcode
sum(a.eatmoney) as eatmoney,d.name as SecTypeName,a.zs as sm from v_sorderdishes a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.eatprice,d.name,a.zs
select a.eatcode,a.unit,(a.price) as eatprice,d.code,a.eatname,sum(a.nums) as eatnums,sum(a.gs) as eatgs,
sum(a.nums*a.price) as eatmoney,d.name as sectypename,a.tmp10 as zs from v_sorderparty a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.price,d.name,a.tmp10 order by a.eatcode
sum(a.eatmoney) as eatmoney,d.name as SecTypeName,a.zs as sm from v_sorderdishes a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.eatprice,d.name,a.zs union all
select '2' as my_, a.eatcode,a.unit,(a.price) as eatprice,d.code,a.eatname,sum(a.nums) as eatnums,sum(a.gs) as eatgs,
sum(a.nums*a.price) as eatmoney,d.name as sectypename,a.tmp10 as zs from v_sorderparty a,bsecondtype d
where a.Seccode = d.code and d.name like '%%' and left(Serial,6) between '091016' and '091016'
group by a.eatname,a.eatcode,a.unit,d.code,a.price,d.name,a.tmp10 order by a.eatcode