59 | | - Кој корисник колку има платено во секој ресторан подредено? |
| 59 | - Кој корисник колку има платено во секој ресторан подредено |
| 60 | {{{#!sql |
| 61 | select k2.user_ime as ime, k2.user_prezime as prezime, r2.restoran_ime as restoran, q1.plateno as plateno from( |
| 62 | select ku.user_id, r.restoran_id, sum(sso.cena * sso.kolicina) as plateno |
| 63 | from korisnik k |
| 64 | join kupuvac as ku on k.user_id =ku.user_id |
| 65 | join naracka as n on ku.user_id =n.user_id_kupuvac |
| 66 | join se_sostoi_od as sso on n.naracka_id =sso.naracka_id |
| 67 | join obrok as o on sso.obrok_id =o.obrok_id |
| 68 | join meni as m on o.meni_id=m.meni_id |
| 69 | join restoran as r on m.restoran_id =r.restoran_id |
| 70 | group by ku.user_id ,r.restoran_id)q1 join korisnik k2 on q1.user_id=k2.user_id join restoran r2 on q1.restoran_id=r2.restoran_id |
| 71 | order by plateno desc |
| 72 | }}} |