Advertisement
Sofe1204

Untitled

Mar 29th, 2022
640
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select q1.klient_id, k.k_ime, b.b_naziv,
  2. max(t.iznos) as max_iznos
  3. from
  4. (
  5.   select kk.klient_id,
  6.   count(distinct s.smetka_br) as broj_smetki,
  7.   count(distinct ol.smetka_br) as broj_ovlas
  8.   from klienti kk
  9.   left join smetki s on s.klient_id = kk.klient_id
  10.   left join ovlasteni_lica ol on ol.smetka_br = s.smetka_br
  11.   and ol.klient_id != s.klient_id
  12.   group by 1
  13. ) q1
  14. join klienti k on q1.klient_id = k.klient_id
  15. join smetki s on s.klient_id = k.klient_id
  16. join banki b on s.banka_id = b.banka_id
  17. left join transakcii t on t.smetka_br = s.smetka_br
  18. where q1.broj_smetki=q1.broj_ovlas
  19. group by 1,2,3
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
Advertisement
RAW Paste Data Copied
Advertisement