| 18 | |
| 19 | * objavite na gazdite i koja e razlikata megju cenata objavena i cenata potpisana za stanot |
| 20 | {{{ |
| 21 | 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 |
| 22 | join apartment_owner ao on ao.ownerid=aa.ownerid |
| 23 | join appuser au on au.userid = ao.ownerid |
| 24 | join apartment apt on apt.apartmentid = aa.apartmentid |
| 25 | join owner_post op on op.ownerid = ao.ownerid |
| 26 | join post p on p.postid = op.owner_postid |
| 27 | order by au.ime,difference |
| 28 | }}} |
| 29 | |
| 30 | * stanovi vo sistemot koi momentalno ne se izdadeni |
| 31 | {{{ |
| 32 | 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 |
| 33 | left join apartment_agreement aa on aa.apartmentid = apt.apartmentid |
| 34 | join apartment_owner ao on ao.ownerid = apt.ownerid |
| 35 | join appuser as a on ao.ownerid = a.userid |
| 36 | join building b on apt.buildingid = b.buildingid |
| 37 | where now()>aa.date_expires or aa.apartment_agreementid isnull |
| 38 | }}} |
| 39 | |
| 40 | * preferenca za roomates na studentot spored objavite |
| 41 | {{{ |
| 42 | select au.userid,au.ime, au.prezime,p.number_of_roommates,count(p.number_of_roommates) as kolku_pati from post as p |
| 43 | join student_post sp on sp.student_postid = p.postid |
| 44 | join student stud on stud.studentid = sp.studentid |
| 45 | join appuser au on stud.studentid = au.userid |
| 46 | group by 1,2,3,4 |
| 47 | order by au.userid, kolku_pati DESC |
| 48 | }}} |
| 49 | |
| 50 | * broj na postovi od owner vo sekoj grad vo minatata godina vo septemvri |
| 51 | {{{ |
| 52 | select a.ime, a.prezime, p.cityname, count(op.ownerid) from apartment_owner ao |
| 53 | join appuser as a on ao.ownerid = a.userid |
| 54 | join owner_post op on ao.ownerid = op.ownerid |
| 55 | join post as p on op.owner_postid = p.postid |
| 56 | where extract(year from p.date_posted)=extract(year from now())-1 |
| 57 | and extract(month from p.date_posted)=9 |
| 58 | group by 1,2,3 |
| 59 | }}} |