var
item:string;
date1,date2:tdatetime;
ds1,ds2:string;
begin
item:=GetPickuplist('select item_name from stock_item order by item_name');
item:=GetSQLStringData('select item_id from stock_item where item_name="'+item+'" ');
GetDateRangeDialog(date1,date2);
ds1:=formatdatetime('yyyy-mm-dd',date1);
ds2:=formatdatetime('yyyy-mm-dd',date2);
ChangReportSQL('SELECT si.item_name, sc.inv_name, sum(out_qty) AS sum_qty '+
' FROM stock_card sc '+
' LEFT OUTER JOIN stock_item si ON si.item_id=sc.item_id '+
' WHERE transaction_date BETWEEN "'+ds1+'" AND "'+ds2+'" '+
' AND transaction_type="OUT" '+
' and sc.item_id="'+item+'" '+
' GROUP BY si.item_id, sc.inv_name');
end;