select (select Good_ID from tb_Good where Left(Good_ID,4)=@SuperGood_ID), (select GoodName from tb_Good where Left(Good_ID,4)=@SuperGood_ID), Sum(tb_Bill_Detail.GoodSum),Sum(tb_Bill_Detail.Total),Avg(tb_Bill_Detail.TaxTotal),Avg(tb_Bill_Detail.Tax_Price),Sum(tb_Bill_Detail.Tax_Total) from tb_Bill_Detail,tb_Bill where tb_Bill_Detail.Good_ID=Good_ID and tb_Bill.ValidDate between @BeginDate and @EndDate and tb_Bill.BillType=@BillType and Client_ID=@Client_ID and TransactID=@StaffID and Depot_ID=@DepotID
(select GoodName from tb_Good where Left(Good_ID,4)=@SuperGood_ID),
Sum(tb_Bill_Detail.GoodSum),Sum(tb_Bill_Detail.Total),Avg(tb_Bill_Detail.TaxTotal),Avg(tb_Bill_Detail.Tax_Price),Sum(tb_Bill_Detail.Tax_Total) from tb_Bill_Detail,tb_Bill
where tb_Bill_Detail.Good_ID=Good_ID and tb_Bill.ValidDate between @BeginDate and @EndDate
and tb_Bill.BillType=@BillType and Client_ID=@Client_ID and TransactID=@StaffID and Depot_ID=@DepotID