Advertisement
Sofe1204

Untitled

Mar 30th, 2022
748
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select b.b_naziv, godina,
  2. (select count(distinct s.smetka_br) from smetki as s
  3. where b.banka_id=s.banka_id) as vkupen_broj_smetki,
  4. (select count(distinct tr.trans_br || '-' || tr.smetka_br)
  5. from smetki as s
  6. join transakcii as tr
  7. on s.smetka_br=tr.smetka_br
  8. where (extract (quarter from tr.datum)=1
  9.       and extract(year from tr.datum)=godini.godina )
  10.       and s.banka_id=b.banka_id) as br_trans_trim_1,
  11.  (select count(distinct tr.trans_br || '-' || tr.smetka_br)
  12. from smetki as s
  13. join transakcii as tr
  14. on s.smetka_br=tr.smetka_br
  15. where (extract (quarter from tr.datum)=2
  16.       and extract(year from tr.datum)=godini.godina )
  17.       and s.banka_id=b.banka_id) as br_trans_trim_2,
  18.  (select count(distinct tr.trans_br || '-' || tr.smetka_br)
  19. from smetki as s
  20. join transakcii as tr
  21. on s.smetka_br=tr.smetka_br
  22. where (extract (quarter from tr.datum)=3
  23.       and extract(year from tr.datum)=godini.godina )
  24.       and s.banka_id=b.banka_id) as br_trans_trim_3,
  25. (select count(distinct tr.trans_br || '-' || tr.smetka_br)
  26. from smetki as s
  27. join transakcii as tr
  28. on s.smetka_br=tr.smetka_br
  29. where (extract (quarter from tr.datum)=4
  30.       and extract(year from tr.datum)=godini.godina )
  31.       and s.banka_id=b.banka_id) as br_trans_trim_4,
  32. (select sum(tr.iznos)
  33. from smetki as s
  34. join transakcii as tr
  35. on s.smetka_br=tr.smetka_br
  36. where (extract (quarter from tr.datum)=1
  37.       and extract(year from tr.datum)=godini.godina )
  38.       and s.banka_id=b.banka_id) as  suma_iznos_trim_1,
  39. (select sum(tr.iznos)
  40. from smetki as s
  41. join transakcii as tr
  42. on s.smetka_br=tr.smetka_br
  43. where (extract (quarter from tr.datum)=2
  44.       and extract(year from tr.datum)=godini.godina )
  45.       and s.banka_id=b.banka_id) as suma_iznos_trim_2,
  46. (select sum(tr.iznos)
  47. from smetki as s
  48. join transakcii as tr
  49. on s.smetka_br=tr.smetka_br
  50. where (extract (quarter from tr.datum)=3
  51.       and extract(year from tr.datum)=godini.godina )
  52.       and s.banka_id=b.banka_id) as suma_iznos_trim_3,
  53. (select sum(tr.iznos)
  54. from smetki as s
  55. join transakcii as tr
  56. on s.smetka_br=tr.smetka_br
  57. where (extract (quarter from tr.datum)=4
  58.       and extract(year from tr.datum)=godini.godina )
  59.       and s.banka_id=b.banka_id) as suma_iznos_trim_4
  60.  
  61. from banki as b,
  62.  
  63. (select distinct extract(year from tr.datum) godina
  64.  from transakcii as tr) godini
  65.  
Advertisement
RAW Paste Data Copied
Advertisement