Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. select *
  2. from
  3. ( select p.requestid, p.reqnum, sum(p.f_productprice) ss , 1 type_
  4. from dwh_procedures_kgntv p
  5. join (select distinct lotuuid from dwh_lot_fin_kgntv where finyear = 2017)f on f.lotuuid = p.lotuuid
  6. where p.reqnum is not null and p.joflag = 0 and p.orgid = 2711
  7. group by p.requestid, p.reqnum
  8. )p
  9. where p.ss>=3000000 and p.ss<40000000
  10. union all
  11. select *
  12. from
  13. ( select p.requestid, p.reqnum, sum(p.f_productprice) ss, 2 type_
  14. from dwh_procedures_cons_kgntv p
  15. join (select distinct lotuuid from dwh_lot_fin_kgntv where finyear = 2017)f on f.lotuuid = p.lotuuid
  16. where p.reqnum is not null and p.orgid = 2711
  17. group by p.requestid, p.reqnum
  18. )p
  19. where p.ss>=3000000 and p.ss<40000000
  20. ;
  21. select p.requestid, p.reqnum,p.f_productprice,1 type_
  22. from dwh_procedures_kgntv p
  23. join (select distinct lotuuid from dwh_lot_fin_kgntv where finyear = 2017)f on f.lotuuid = p.lotuuid
  24. where p.reqnum is not null and uo_orgid = 2711 and p.joflag = 0
  25. union all
  26. select p.requestid, p.reqnum,p.f_productprice,2 type_
  27. from dwh_procedures_cons_kgntv p
  28. join (select distinct lotuuid from dwh_lot_fin_kgntv where finyear = 2017)f on f.lotuuid = p.lotuuid
  29. where p.reqnum is not null and uo_orgid = 2711
  30. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement