SQL Query
SQL Query
Output:
Month_wise_Balance_Transfer flow:-
select year(Disbursement_Date) as 'YEAR',
month(Disbursement_Date) as 'Month',
concat(datename(Month,Disbursement_Date),'-',year(Disbursement_Date)) as Month_Name,
count(App_id) as No_of_Loans,
concat(round(sum(Applied_Amount)/1000000,1),' ','Mn') as Disb_Amount
from data_task where [BT Yes/No]='Yes' group by
Year(Disbursement_Date),month(Disbursement_Date),datename(Month,Disbursement_Date) order
by 1,2
select 'GrandTotal' as Grand_Total,COUNT(App_id) as
No_of_Loans,round(sum(Applied_Amount)/1000000,1) as Disb_Amount
from data_task where [BT Yes/No]='Yes'
output:
Balance transfer loans wise details
select BT_Name,
count(App_id) as No_of_Loans,
concat(round(sum(Applied_Amount)/1000000,1),' ','Mn') as Disb_Amount
from data_task where [BT Yes/No]='Yes' group by Bt_Name
select 'GrandTotal' as Grand_Total,COUNT(App_id) as
No_of_Loans,concat(round(sum(Applied_Amount)/1000000,1),' ','Mn') as Disb_Amount
from data_task where BT_Name in('Fullerton India Credit Company Limited','idfc first
bank ltd','INCRED FINANCIAL SERVICES LIMITED','Riviera Investors Pvt. Ltd.')
Output:
Bucket_wise_DIsb_Amount:-
use random
go
select * from (select Loan_Buckets,Month_Data,[Applied_Amount] from data_task) ResultSEt
PIVOT
(
SUM([Applied_Amount]) for [Month_Data] IN (
[Aug-2021],[Sep-2021],[Oct-2021],
[Nov-2021],[Dec-2021],[Jan-2022]
)
) as pivottable
select 'GrandTotal' as Grand_Total,concat(round(sum(Applied_Amount)/1000000,1),' ','Mn')
as Disb_Amount
from data_task
select * from (select Loan_Buckets,Month_Data,[App_id] from data_task ) ResultSEt
PIVOT
(
count([App_id]) for [Month_Data] IN (
[Aug-2021],[Sep-2021],[Oct-2021],
[Nov-2021],[Dec-2021],[Jan-2022]
)
) as pivottable
select 'GrandTotal' as Grand_Total,COUNT(App_id) as No_of_Loans
from data_task
Output:-
Avg_Loan_size:
select round(SUM(Applied_Amount)/count(App_id),2) as Average_Loan_size from data_task
Output:
Disbursement_Details:-
select count(App_id) as Disb_Loans ,round(SUM(Applied_Amount/1000000),2) as Disb__amt
from data_task
select count(App_id) as Paid_to_client_Loans ,round(SUM(Paid_to_client/1000000),2) as
Paid__to_client_amt,
(round(SUM(Paid_to_client/1000000)/SUM(Applied_Amount/1000000),4))*100 as amt
from data_task
select count(LPF) as Disb_Loans ,round(SUM(LPF)/1000000,2) as Disb__amt,
(round(SUM(LPF/1000000)/SUM(Applied_Amount/1000000),4))*100 as amt from data_task
select count(Pre_EMI) as Disb_Loans ,round(SUM(Pre_EMI)/1000000,1) as Disb__amt,
(round(SUM(Pre_EMI/1000000)/SUM(Applied_Amount/1000000),4))*100 as amt from data_task
select count(Insurance) as Disb_Loans ,round(SUM(Insurance)/1000000,1),
(round(SUM(Insurance/1000000)/SUM(Applied_Amount/1000000),4))*100 as Disb__amt from
data_task
select count(Balance_transfer) as Disb_Loans ,round(SUM(Balance_transfer/1000000),2) as
Disb__amt
from data_task where [BT Yes/No]='Yes'
select (round(SUM(Balance_transfer/1000000)/SUM(Applied_Amount/1000000),4))*100 as
percentage from data_task
Output: