| 4 | {{{#!sql |
| 5 | create view pacient_najmnogu_pregledi as |
| 6 | select pacient_id ,covek.ime,covek.prezime, count (pregled.pregled_id) pacientot_bil_na_pregled |
| 7 | from pacient as p |
| 8 | join pregled as pregled on pregled.covek_pacient_id=p.covek_pacient_id |
| 9 | join covek as covek on covek.covek_id=p.covek_pacient_id |
| 10 | group by p.pacient_id,covek.covek_id; |
| 11 | |
| 12 | select pnp.ime, pnp.prezime ,pnp.pacient_id , pnp.pacientot_bil_na_pregled as broj_pregledi |
| 13 | from pacient_najmnogu_pregledi as pnp |
| 14 | where pnp.pacientot_bil_na_pregled= |
| 15 | (select max(pacientot_bil_na_pregled) from pacient_najmnogu_pregledi); |
| 16 | }}} |