And still slightly)

There is a table of debtors (person):

Id_person, FIO

1, Ivanov I.I.

2, Petrov I.I.

3, Sidorov. ..

4, Sergeev I.I.

Etc.

There is a table of debts (debt):

Id_person, Id_debt, Id_portfolio, Debt_sum

1,1,1,100

1,2,2,200

3,3,1,300

4,4,3,400

Etc.

There is a table of briefcases (portfolio):

Id_portfolio,Pportfolio_name,Sign_date,End_date

1, PORTFOLIO_1,01.01.2011,21.01.2013

2, PORTFOLIO_2,06.05.2012,20.09.2012

3, PORTFOLIO_3,21.11.2012,16.03.2013

4, PORTFOLIO_4,01.12.2012,11.06.2013

Etc.

There is a table of months (the first day of each month) (calendar):

Cal_date

01.01.2011

01.02.2011

01.03.2011

01.04.2011

Etc.

There is a table payments (payment):

Id_debt, Payment_sum, Date

1,10,12.05.2012

1,20,28.05.2012

3,30,10.06.2012

4,10,01.12.2012

Etc.

IT IS REQUIRED:

To select debtors with the total to collecting (the total of all debts of the debtor) more than 150 roubles

On every month to count a briefcase in operation.

Briefcase in operation - the total of debts which were in operation at least one day in a month:

Cal_date, Portfolio_sum

..., ...

01.05.2012,600

..., ...

01.12.2012,800

Etc.

To count efficiency on each briefcase (the total of all payments/sums of all debts):

Portfolio_name, Efficiency

PORTFOLIO_1,15%

PORTFOLIO_2,0%

PORTFOLIO_3,2.5%

Etc.

To count efficiency in every month (the total of all payments for month/portfolio of operation for a month)

Cal_date, Efficiency

..., ...

01.05.2012,5%

..., ...

01.12.2012,1.25%

Etc.

To select all debts without payments