20 | | select au.ime,au.prezime,p.cityname as city_posted_for,p.price as posted_price, aa.apartment_rent as signed_price, abs(p.price-aa.apartment_rent) as difference from apartment_agreement as aa |
| 20 | select au.ime as student_ime,au.prezime as student_prezime, aa.apartment_rent as rent, aa.apartment_rent * extract(month from age(aa.date_expires,aa.date_signed)) as total_paid, |
| 21 | appu.ime as owner_ime, appu.prezime as owner_prezime, aa.date_signed, aa.date_expires from student s |
| 22 | join appuser au on au.userid=s.studentid |
| 23 | left join student_signs ss on ss.studentid = s.studentid |
| 24 | left join apartment_agreement aa on aa.apartment_agreementid=ss.agreementid |
| 25 | join apartment_owner ao on ao.ownerid=aa.ownerid |
| 26 | join appuser appu on appu.userid = ao.ownerid |
| 27 | order by au.ime,aa.date_signed |
| 28 | }}} |
| 29 | |
| 30 | * Објавите на газдите и која е разликата меѓу цената објавена и цената потпишана за станот, и колку вкупно имаат заработено во тој договор. |
| 31 | {{{ |
| 32 | select au.ime,au.prezime,p.cityname as city_posted_for,p.price as posted_price, aa.apartment_rent as signed_price, abs(p.price-aa.apartment_rent) as difference, aa.apartment_rent * extract(month from age(aa.date_expires,aa.date_signed)) as total_euros_earned from apartment_agreement as aa |
31 | | select apt.apartmentid,concat(b.cityname,', ',b.building_adress,' ',apt.apartment_adress) as adresa, a.ime, a.prezime, a.phone_number from apartment as apt |
| 43 | select distinct apart.apartmentid,apart.adresa as adresa, apart.ime, apart.prezime, apart.phone_number, au.ime,au.prezime,aa2.date_signed,aa2.date_expires from student s |
| 44 | join student_signs ss on ss.studentid = s.studentid |
| 45 | join appuser au on au.userid = s.studentid |
| 46 | join apartment_agreement aa2 on aa2.apartment_agreementid = ss.agreementid |
| 47 | right join |
| 48 | ( |
| 49 | select distinct apt.apartmentid,concat(b.cityname,', ',b.building_adress,' ',apt.apartment_adress) as adresa, a.ime, a.prezime, a.phone_number from apartment as apt |