| 1 | = Напредни извештаи од базата |
| 2 | |
| 3 | * za odreden student kolku pati ima sedeno vo sekoj od stanovite kade ima sedeno i kolku vkupno ima plateno vo tekot na site dogovori |
| 4 | |
| 5 | {{{ |
| 6 | select stud.studentid, appus.ime, appus.prezime, b.cityname, b.building_adress, apt.apartment_adress, aa.date_signed,apt.apartmentid,aa.date_signed,aa.date_expires, count(apt.apartmentid) as kolku_pati, extract(month from age(aa.date_expires,aa.date_signed)) * sum(aa.apartment_rent) as vkupno_plateno from apartment_agreement as aa |
| 7 | join apartment apt on apt.apartmentid = aa.apartmentid |
| 8 | join student_signs ss on ss.agreementid = aa.apartment_agreementid |
| 9 | join student stud on stud.studentid = ss.studentid |
| 10 | join appuser appus on appus.userid = stud.studentid |
| 11 | join building b on apt.buildingid = b.buildingid |
| 12 | group by 1,2,3,4,5,6,7,8,9,10 |
| 13 | order by stud.studentid |
| 14 | }}} |