
Help constructing a query
5106
$$
- Posted:
- Proposals: 0
- Remote
- #152471
- Archived
Description
Experience Level: Intermediate
I have customers who purchase tickets for events.
Each customer has the ability to promote events as an affiliate.
Every ticket sold as an affiliate generates commission for the affiliate.
If the purchaser also decides to become an affiliate an affiliate hierarchy
begins and any commission earned to filtered up the hierarchy.
This is the COMMISSION table
Id CommBandId Name Commission Level
1 1 Standard 1.00 1
2 1 Standard 0.50 2
3 1 Standard 0.25 3
4 2 Special 0.50 1
5 2 Special 0.10 2
The query I need to generate should walk up the hierarchy recursively
from the point the ticket is purchased applying commission to each
of the parent affiliates until no more parents are found.
The commission should be paid as follows:
When the ticket is purchased the direct parent should receive LEVEL 1
commission as shown in the table.
The parent of that parent should receive LEVEL 2 commission and so on
until all the levels are processed or until no more parents exist to
apply commission too.
I hope this kinda makes sense. I'm looking for some help on constructing
this query, examples of where this happens or example sql based on a
mock up of a similar set of tables...
Each customer has the ability to promote events as an affiliate.
Every ticket sold as an affiliate generates commission for the affiliate.
If the purchaser also decides to become an affiliate an affiliate hierarchy
begins and any commission earned to filtered up the hierarchy.
This is the COMMISSION table
Id CommBandId Name Commission Level
1 1 Standard 1.00 1
2 1 Standard 0.50 2
3 1 Standard 0.25 3
4 2 Special 0.50 1
5 2 Special 0.10 2
The query I need to generate should walk up the hierarchy recursively
from the point the ticket is purchased applying commission to each
of the parent affiliates until no more parents are found.
The commission should be paid as follows:
When the ticket is purchased the direct parent should receive LEVEL 1
commission as shown in the table.
The parent of that parent should receive LEVEL 2 commission and so on
until all the levels are processed or until no more parents exist to
apply commission too.
I hope this kinda makes sense. I'm looking for some help on constructing
this query, examples of where this happens or example sql based on a
mock up of a similar set of tables...
Paul W.
100% (1)Projects Completed
5
Freelancers worked with
5
Projects awarded
14%
Last project
18 Aug 2017
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies