I have a table named clients that stores client data
id | fname | lname --- | ------ | ------ 1 | John | Smith 2 | Mike | Bolton 3 | Liz | John 4 | Mark | Jobs
And I have another table with names that supports every call made to every customer.
id | timestamp | customer_id | campaign | answered | 1 |2016-09-05 15:24:08| 1 | 2016-09 | 1 | 2 |2016-09-05 15:20:08| 2 | 2016-09 | 1 | 3 |2016-08-05 15:20:08| 2 | 2016-08 | 1 | 4 |2016-08-05 13:20:08| 3 | 2016-08 | 1 | 5 |2016-08-01 15:20:08| 3 | 2016-08 | 0 | 5 |2016-08-01 12:20:08| 4 | General | 1 |
Campaign General Not taken into account in the calculations.
I need to get a list of clients sorted by call quality ranking based on each clientβs history.
This list is used to call clients to:
- Has not been called into a valid calling campaign (e.g. 2016-09 )
- less calls
- Best% answer (total number of calls or total calls)
It should look something like this:
| id | fname | lname | %ans | called actual campaign | total calls | rank | |----|--------|-------|------|------------------------|-------------|------| | 4 | Mark | Jobs | N/A | no | 0 | 1 | | 3 | Liz | John | 50 | no | 2 | 2 | | 1 | John | Smith | 100 | yes | 1 | 3 | No Show | 2 | Mike | Bolton| 100 | yes | 2 | 4 | No Show
Please help me!
source share