I have 2 tables
1st INVHD
2nd INVDT
In INVHD I have following fields
InvNo, InvDate,CustCd, CustName, TotalDisc (Discount on total Invoice), GrandTotal
In INVDT I have following fields
InvNo, RowNo,ItemCode, Qty, Rate, BaseVal, etc….
Now I need a query to be generated for
The customer
CustCd, CustName, Sum(totalDisc), Sum(GrandTotal) , sum(BaseVal)
For given period primary key is InvNo