-1

I have a simple query with a simple table

SELECT Call_Date, Phone_Num, Call_Type
FROM IVR_TBL

the result like

CALL_DATE            |Phone_Num       |CALL_TYPE |
---------------------|----------------|----------|
2020-01-30 21:12:0   |0553748547      |Technical |
2020-02-23 21:10:0   |0224643303      |Sales     |
2020-05-01 09:00:0   |0224432454      |Technical |
2020-04-02 09:05:0   |0453652041      |Technical |
2020-03-30 08:59:0   |0934604076      |Sales     |
2020-02-28 21:17:0   |0244794546      |Sales     |
2020-01-23 21:20:0   |0238441865      |Sales     |
2020-05-16 21:18:0   |0552715113      |Sales     |
2020-04-28 21:22:0   |0502132405      |Technical |

how could I get the

  • Percentage of Distinct customers calls report (from Phone_Num) within 1 month (Customers who contacted us 1 time during a month) and group them by CALL_TYPE

  • Percentage of Distinct customers calls report (from Phone_Num) within 4 months (Customers who contacted us 1 time during the 4 months ) and group them by CALL_TYPE

the result for 1 Month will contain 3 fields only like below

Month   |Call_Type  |Percentage  |
--------|-----------|------------|
Jan     |Sales      |            |
Feb     |Sales      |            |  
Mar     |Sales      |            |  
Apr     |Sales      |            |  
May     |Sales      |            |  
Jan     |Technical  |            |
Feb     |Technical  |            |  
Mar     |Technical  |            |  
Apr     |Technical  |            |  
May     |Technical  |            |  

and another table for the result of 4 Months that contain also to get the count of customers who called us one time during the duration from Jan to Apr

Month   |Call_Type  |Percentage  |
--------|-----------|------------|
Jan     |Sales      |            |
Jan     |Technical  |            |  

The dataset is from the beginning of 2020

1 Answers1

0

Below query provides you the count of each customer with respect to the months. You can filter it out further according to your requirement.

SELECT TO_CHAR( DATE Call_Date,'YYYY-MM-DD'), Phone_Num, Call_Type, count(1)
FROM IVR_TBL where 
group by TO_CHAR( DATE Call_Date,'YYYY-MM-DD'), Phone_Num, Call_Type
halfer
  • 19,824
  • 17
  • 99
  • 186
Jim Macaulay
  • 4,709
  • 4
  • 28
  • 53