Answer the question
In order to leave comments, you need to log in
How to get the number of overdue loans?
There is a table with data about borrowers
CREATE TABLE customers
(
customer_id integer,
region_id integer,
created date
);
CREATE TABLE regions
(
region_id integer,
timezone varchar(255)
);
CREATE TABLE applications
(
application_id integer,
credit_date date,
customer_id integer,
back_date date,
credit_sum decimal(8, 2)
);
CREATE TABLE payments
(
application_id integer,
created_at date,
payment decimal(8, 2)
);
select to_char(applications.credit_date, 'DD.MM.YYYY') as Дата_займа,
applications.credit_sum as Сумма_займа,
count(applications.credit_sum) as Количество_займов,
sum(applications.credit_sum) * count(distinct(applications.credit_sum)) as Сумма_займов_руб,
from applications
group by to_char(applications.credit_date, 'DD.MM.YYYY'), applications.credit_sum
order by to_char(applications.credit_date, 'DD.MM.YYYY'), applications.credit_sum
Answer the question
In order to leave comments, you need to log in
it is difficult to understand the task, there is little information, examples of data with explanations are needed
applications.back_date most likely contains the date of repayment of the debt, so if it is null, then applications.customer_id will refer to the debtor? so count these count(applications.id) for group by applications.customer_id with the condition applications.back_date is null
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question