Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. select * from sysdba.opportunity where description ='leaseline program q3 2018'
  2.  
  3. select * from sysdba.opportunity_product where OPPORTUNITYID='O6UJ9A002BWM' and sort = 22
  4.  
  5.  
  6. --opportunity_product 1 ROW
  7. oid = O6UJ9A002BWM
  8. oppid = Q6UJ9A03BDT0
  9. quantity = 30
  10. price = null
  11. calc price = 1347.0000
  12. ext = 40410.0000
  13. vendor calcprice = 1347
  14.  
  15. select * from sysdba.C_OPPTY_LEASE_REV where OPPPRODUCTID='Q6UJ9A03BDT0'
  16. --C_OPPTY_LEASE_REV 6 ROWS (all on different leases)
  17. quantity = 30
  18. price = 1347.0000
  19. calc price = 1347.0000
  20. ext = 40410.0000
  21. vendor calcprice = 1347.0000
  22.  
  23. select * from sysdba.C_OPPTY_LEASEAWARD_REV where OPPPRODUCTID='Q6UJ9A03BDT0'
  24. --C_OPPTY_LEASEAWARD_REV 1 ROW
  25. quantity = 30
  26. price = 1347.0000
  27. calc price = 1347.0000
  28. ext = 40410.0000
  29. vendor calcprice = 1347.0000
  30.  
  31. select SALESORDERID from sysdba.salesorder where opportunityid='O6UJ9A002BWM'
  32. soid = Q6UJ9A039IRX
  33.  
  34. --exhibit main call
  35. SELECT ACTUALID, PRODUCT, price, RENTCOMMENCE, RentalRate, PONum, SERIALNUM, REPLACESERIALNUMBER,
  36. VENDOR, equip_Address,Taxable,InvoiceNumber,CustomerPONumber as LeseeRefNum
  37. FROM sysdba.vwExhibit
  38. WHERE SALESORDERID = 'Q6UJ9A039IRX' and actualid like 'Zbook 17'
  39. order by equip_address, RENTCOMMENCE, assetnum
  40.  
  41. --There are 61 rows of zbooks.
  42. --30 rows have price 1347
  43. --31 rows have price of 1389
  44. SELECT ACTUALID, price, count(SERIALNUM) x
  45. FROM sysdba.vwExhibit
  46. WHERE SALESORDERID = 'Q6UJ9A039IRX' and actualid like 'Zbook 17'
  47. group by ACTUALID, price
  48.  
  49.  
  50. --Looking back at the opp for all zbooks we see there are 8 different rows of them
  51. --OPPORTUNITY_PRODUCT 8 ROWS
  52. select quantity, calcprice, oppproductid from sysdba.opportunity_product where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17'
  53. 10 1347.0000 Q6UJ9A03B1K8
  54. 40 1389.0000 Q6UJ9A039OKE
  55. 10 1347.0000 Q6UJ9A03DCS9
  56. 30 1347.0000 Q6UJ9A03AKWW
  57. 10 1347.0000 Q6UJ9A03CEJE
  58. 20 1389.0000 Q6UJ9A03AGWQ
  59. 40 1389.0000 Q6UJ9A03AGWR
  60. 30 1347.0000 Q6UJ9A03BDT0
  61.  
  62. --OPPORTUNITY_PRODUCT 8 ROWS
  63. select quantity, CALCPRICE, oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17'
  64. 30 1347.0000 Q6UJ9A03BDT0
  65. 20 1389.0000 Q6UJ9A03AGWQ
  66. 40 1389.0000 Q6UJ9A03AGWR
  67. 10 1347.0000 Q6UJ9A03B1K8
  68. 40 1389.0000 Q6UJ9A039OKE
  69. 10 1347.0000 Q6UJ9A03DCS9
  70. 30 1347.0000 Q6UJ9A03AKWW
  71. 10 1347.0000 Q6UJ9A03CEJE
  72.  
  73. --Looking at the data in the salesorderitems table, rolloing up the products to match the oppportunity multi-quantity line:
  74. --There are 8 rows
  75. select sum(a.quantity) quantity, a.price, a.oppproductid from
  76. sysdba.SALESORDERITEMS a left join sysdba.C_SALESORDER b on a.SALESORDERID=b.SALESORDERID
  77. where a.OPPPRODUCTID in
  78. (select oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17')
  79. group by b.LEASENUM, a.OPPPRODUCTID, a.price
  80. 40 1389 Q6UJ9A039OKE
  81. 20 1389 Q6UJ9A03AGWQ
  82. 40 1389 Q6UJ9A03AGWR
  83. 30 1347 Q6UJ9A03AKWW
  84. 10 1347 Q6UJ9A03B1K8
  85. 30 1347 Q6UJ9A03BDT0
  86. 10 1347 Q6UJ9A03CEJE
  87. 10 1347 Q6UJ9A03DCS9
  88.  
  89.  
  90. --So, what is the vwExhibit SQL view???
  91. --It has conditions included of c_lip_Po.docoutdate is null and c_lip_po.ac is not null
  92.  
  93. --If we look at the salesorder data again with that condition applied:
  94. select sum(a.quantity) quantity, a.price, a.oppproductid from
  95. sysdba.SALESORDERITEMS a left join sysdba.C_SALESORDER b on a.SALESORDERID=b.SALESORDERID left join
  96. sysdba.C_LIP_PO AS A12 ON a.SALESORDERITEMSID = A12.SALESORDERITEMSID
  97. where a.OPPPRODUCTID in
  98. (select oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17')
  99. and
  100. (A12.DOCOUTDATE IS NULL) AND (A12.AC IS NOT NULL)
  101. group by b.LEASENUM, a.OPPPRODUCTID, a.price
  102. --The result is this:
  103. 31 1389 Q6UJ9A03AGWR
  104. 10 1347 Q6UJ9A03B1K8
  105. 10 1347 Q6UJ9A03CEJE
  106. 10 1347 Q6UJ9A03DCS9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement