Advertisement
Sofe1204

Untitled

Mar 29th, 2022
703
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select k.k_ime, k.k_embg,
  2. godina,
  3.  
  4. (
  5.   select count(distinct t.trans_br || '-' || t.smetka_br)
  6.   from transakcii t
  7.   left join smetki s on t.smetka_br = s.smetka_br
  8.   where extract(quarter from t.datum)=1 and
  9.   extract(year from t.datum)=godina and
  10.   s.klient_id = k.klient_id
  11. ) as br_trans_trim_1,
  12.  
  13. (
  14.   select count(distinct t.trans_br || '-' || t.smetka_br)
  15.   from transakcii t
  16.   left join smetki s on t.smetka_br = s.smetka_br
  17.   where extract(quarter from t.datum)=2 and
  18.   extract(year from t.datum)=godina and
  19.   s.klient_id = k.klient_id
  20. ) as br_trans_trim_2,
  21.  
  22. (
  23.   select count(distinct t.trans_br || '-' || t.smetka_br)
  24.   from transakcii t
  25.   left join smetki s on t.smetka_br = s.smetka_br
  26.   where extract(quarter from t.datum)=3 and
  27.   extract(year from t.datum)=godina and
  28.   s.klient_id = k.klient_id
  29. ) as br_trans_trim_3,
  30.  
  31. (
  32.   select count(distinct t.trans_br || '-' || t.smetka_br)
  33.   from transakcii t
  34.   left join smetki s on t.smetka_br = s.smetka_br
  35.   where extract(quarter from t.datum)=4 and
  36.   extract(year from t.datum)=godina and
  37.   s.klient_id = k.klient_id
  38. ) as br_trans_trim_4,
  39.  
  40. (
  41.   select avg(t.iznos)
  42.   from transakcii t
  43.   left join smetki s on t.smetka_br = s.smetka_br
  44.   where extract(quarter from t.datum)=1 and
  45.   extract(year from t.datum)=godina and
  46.   s.klient_id = k.klient_id
  47. ) as prosek_iznos_trim_1,
  48.  
  49. (
  50.   select avg(t.iznos)
  51.   from transakcii t
  52.   left join smetki s on t.smetka_br = s.smetka_br
  53.   where extract(quarter from t.datum)=2 and
  54.   extract(year from t.datum)=godina and
  55.   s.klient_id = k.klient_id
  56. ) as prosek_iznos_trim_2,
  57.  
  58. (
  59.   select avg(t.iznos)
  60.   from transakcii t
  61.   left join smetki s on t.smetka_br = s.smetka_br
  62.   where extract(quarter from t.datum)=3 and
  63.   extract(year from t.datum)=godina and
  64.   s.klient_id = k.klient_id
  65. ) as prosek_iznos_trim_3,
  66.  
  67. (
  68.   select avg(t.iznos)
  69.   from transakcii t
  70.   left join smetki s on t.smetka_br = s.smetka_br
  71.   where extract(quarter from t.datum)=4 and
  72.   extract(year from t.datum)=godina and
  73.   s.klient_id = k.klient_id
  74. ) as prosek_iznos_trim_4
  75.  
  76. from klienti k,
  77. (select distinct extract(year from t.datum) godina
  78. from transakcii t) godini
Advertisement
RAW Paste Data Copied
Advertisement