"left join customer_table b on a.customer_list_id = b.customerListId\n"+
"left join campaign_customer_table c on a.customer_list_id = c.customerListId\n"+
"left join customer_interactive_table d on a.customer_list_id = d.customerListId\n"+
"left join customer_not_interactive_table e on a.customer_list_id = e.customerListId\n"+
"where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)\n"+
"),\n"+
"data as (\n"+
"select a.*, rownum row_ from data_temp a\n"+
"),\n"+
"count_data as (\n"+
"select count(*) totalRow from data_temp\n"+
")\n"+
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusCampaign, a.totalCusCalled, a.totalCusNotInteract, totalRow from data a, count_data\n"+
sb.append(" left join customer_table b on a.customer_list_id = b.customerListId");
sb.append(" left join customer_active_table c on a.customer_list_id = c.customerListId");
sb.append(" left join customer_lock_table d on a.customer_list_id = d.customerListId");
sb.append(" left join customer_dnc_table e on a.customer_list_id = e.customerListId");
sb.append(" where a.status = 1");
sb.append(" and (:p_cus_list_code is null or upper(a.customer_list_code) like '%'||:p_cus_list_code||'%')");
sb.append(" and (:p_cus_list_name is null or upper(a.customer_list_name) like '%'||:p_cus_list_name||'%')");
sb.append(" and (a.create_at <= to_date(:p_to_date, 'DD/MM/YYYY'))");
sb.append(" and (a.create_at >= to_date(:p_from_date, 'DD/MM/YYYY'))");
sb.append(" and (a.company_site_id = :p_company_site_id)");
sb.append(" and (a.customer_list_id not in (select CUSTOMER_LIST_ID from campaign_customer_id))");
sb.append(" ),");
sb.append(" data as (");
sb.append(" select a.*, rownum row_ from data_temp a");
sb.append(" ),");
sb.append(" count_data as (");
sb.append(" select count(*) totalRow from data_temp");
sb.append(" )");
sb.append(" select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, totalRow from data a, count_data");
sb.append(" where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)");
" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl\n"+
" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id\n"+
"),\n"+
"customer_table as (\n"+
" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a\n"+
" left join customer b on a.customer_id = b.customer_id\n"+
" where b.status = 1\n"+
" group by a.customer_list_id\n"+
"),\n"+
"customer_active_table as (\n"+
" select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a\n"+
" left join customer b on a.customer_id = b.customer_id\n"+
" where b.status = 1 and b.ipcc_status = 'active'\n"+
" group by a.customer_list_id\n"+
"),\n"+
"customer_lock_table as (\n"+
" select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a\n"+
" left join customer b on a.customer_id = b.customer_id\n"+
" where b.status = 1 and b.ipcc_status = 'locked'\n"+
" group by a.customer_list_id\n"+
"),\n"+
"customer_dnc_table as (\n"+
" select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a\n"+
" left join customer b on a.customer_id = b.customer_id\n"+
" where b.status = 1 and b.call_allowed = 0\n"+
" group by a.customer_list_id\n"+
"),\n"+
"customer_filter_table as (\n"+
" select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a\n"+
" where a.campaign_id = :p_campaign_id\n"+
" group by a.customer_list_id\n"+
"),\n"+
"data_temp as (\n"+
"select a.customer_list_id customerListId,\n"+
" a.customer_list_code customerListCode,\n"+
" a.customer_list_name customerListName,\n"+
" nvl(b.totalCustomer, 0) totalCusList,\n"+
" nvl(c.customerActive, 0) totalCusActive,\n"+
" nvl(d.customerLock, 0) totalCusLock,\n"+
" nvl(e.customerDnc, 0) totalCusDnc,\n"+
" nvl(null, 0) totalCusAddRemove,\n"+
" nvl(f.customerFilter, 0) totalCusFilter\n"+
"from customer_list a\n"+
"left join customer_table b on a.customer_list_id = b.customerListId\n"+
"left join customer_active_table c on a.customer_list_id = c.customerListId\n"+
"left join customer_lock_table d on a.customer_list_id = d.customerListId\n"+
"left join customer_dnc_table e on a.customer_list_id = e.customerListId\n"+
"left join customer_filter_table f on a.customer_list_id = f.customerListId\n"+
"where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)\n"+
"),\n"+
"data as (\n"+
"select a.*, rownum row_ from data_temp a\n"+
"),\n"+
"count_data as (\n"+
"select count(*) totalRow from data_temp\n"+
")\n"+
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter totalRow from data a, count_data\n"+