We are getting order wise details in a table
order | orderDate | order value | commission | partner1 | partner2 | partner3 |
---|---|---|---|---|---|---|
1 | 1-Oct | 1000 | 50 | A | B | C |
2 | 1-Oct | 800 | 40 | C | D | F |
3 | 2-Oct | 2000 | 100 | B | A | K |
This commission will be divided into multiple partners based on predefined formula
Need to create daily & monthly earning for each partner so that amount can be given to them based on their earning
PartnerID | startdate | enddate | total earning |
---|---|---|---|
A | 1-Oct | 20-Oct | 500 |
B | 1-Oct | 20-Oct | 300 |
I need to write a stored procedure in SQL Server to make this daily & monthly earning report partner wise