This document contains SQL statements to insert aggregated data from a bill_Tran table into a temporary #Rpt_cash table and non-aggregated data from the same bill_Tran table into a temporary #temp table. The data is filtered for a given machine_no and date range and summed or grouped on various fields for the #Rpt_cash table, while all matching raw records are inserted into #temp.
This document contains SQL statements to insert aggregated data from a bill_Tran table into a temporary #Rpt_cash table and non-aggregated data from the same bill_Tran table into a temporary #temp table. The data is filtered for a given machine_no and date range and summed or grouped on various fields for the #Rpt_cash table, while all matching raw records are inserted into #temp.
This document contains SQL statements to insert aggregated data from a bill_Tran table into a temporary #Rpt_cash table and non-aggregated data from the same bill_Tran table into a temporary #temp table. The data is filtered for a given machine_no and date range and summed or grouped on various fields for the #Rpt_cash table, while all matching raw records are inserted into #temp.
tamt, SUM(tran_amt2), Sum(tran_qty) tqty, tran_cat, tran_type, tran_desc, key_code, price_type From bill_Tran where mech_no = @machine_no and bill_date between @entry_date and @to_date GROUP BY type_code, tran_cat, tran_type, tran_desc, key_code, price_type ) insert into #temp (Type_code ,Tran_amt, tran_amt2, tran_qty,tran_cat, tran_type, mech_no, clerk_code, key_code, price_type) (Select type_code, tran_amt, tran_amt2 ,tran_qty, tran_cat, tran_type, mech_no, clrk_code,key_code, price_type From bill_tran where mech_no = @machine_no AND bill_date between @entry_date and @to_date)