M
M
marselabdullin2020-08-06 16:41:49
SQL
marselabdullin, 2020-08-06 16:41:49

How to find start date of loan delinquency sql?

I have a table in this format:

Date 	     Customer   Deal   Currency Sum 
12.12.2019 	111110 	111111 	RUR 	12000 
25.12.2019 	111110 	111111 	RUR 	5000 
12.12.2019 	111110 	122222 	RUR 	10000 
12.01.2020 	111110 	111111 	RUR 	-10100 
20.11.2019 	220000 	222221 	RUR 	25000 
20.12.2019 	220000 	222221 	RUR 	-25000 
21.12.2019 	220000 	222221 	RUR 	20000 
29.12.2019 	111110 	122222 	RUR 	-10000

I output the amount of debt of people who are in arrears on the loan using this code:

select deal, sum(payment_sum) as "Невыпл_сум" from pdcl
having sum(payment_sum) > 0
group by deal


Now I need to display the start date of the delay (for example, for deal 111111 it is 12/12/2019) and just min(date) does not come out because it is looking for the minimum string, not the date

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-08-06
@tsklab

Running total (window functions).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question