Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from sysdba.opportunity where description ='leaseline program q3 2018'
- select * from sysdba.opportunity_product where OPPORTUNITYID='O6UJ9A002BWM' and sort = 22
- --opportunity_product 1 ROW
- oid = O6UJ9A002BWM
- oppid = Q6UJ9A03BDT0
- quantity = 30
- price = null
- calc price = 1347.0000
- ext = 40410.0000
- vendor calcprice = 1347
- select * from sysdba.C_OPPTY_LEASE_REV where OPPPRODUCTID='Q6UJ9A03BDT0'
- --C_OPPTY_LEASE_REV 6 ROWS (all on different leases)
- quantity = 30
- price = 1347.0000
- calc price = 1347.0000
- ext = 40410.0000
- vendor calcprice = 1347.0000
- select * from sysdba.C_OPPTY_LEASEAWARD_REV where OPPPRODUCTID='Q6UJ9A03BDT0'
- --C_OPPTY_LEASEAWARD_REV 1 ROW
- quantity = 30
- price = 1347.0000
- calc price = 1347.0000
- ext = 40410.0000
- vendor calcprice = 1347.0000
- select SALESORDERID from sysdba.salesorder where opportunityid='O6UJ9A002BWM'
- soid = Q6UJ9A039IRX
- --exhibit main call
- SELECT ACTUALID, PRODUCT, price, RENTCOMMENCE, RentalRate, PONum, SERIALNUM, REPLACESERIALNUMBER,
- VENDOR, equip_Address,Taxable,InvoiceNumber,CustomerPONumber as LeseeRefNum
- FROM sysdba.vwExhibit
- WHERE SALESORDERID = 'Q6UJ9A039IRX' and actualid like 'Zbook 17'
- order by equip_address, RENTCOMMENCE, assetnum
- --There are 61 rows of zbooks.
- --30 rows have price 1347
- --31 rows have price of 1389
- SELECT ACTUALID, price, count(SERIALNUM) x
- FROM sysdba.vwExhibit
- WHERE SALESORDERID = 'Q6UJ9A039IRX' and actualid like 'Zbook 17'
- group by ACTUALID, price
- --Looking back at the opp for all zbooks we see there are 8 different rows of them
- --OPPORTUNITY_PRODUCT 8 ROWS
- select quantity, calcprice, oppproductid from sysdba.opportunity_product where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17'
- 10 1347.0000 Q6UJ9A03B1K8
- 40 1389.0000 Q6UJ9A039OKE
- 10 1347.0000 Q6UJ9A03DCS9
- 30 1347.0000 Q6UJ9A03AKWW
- 10 1347.0000 Q6UJ9A03CEJE
- 20 1389.0000 Q6UJ9A03AGWQ
- 40 1389.0000 Q6UJ9A03AGWR
- 30 1347.0000 Q6UJ9A03BDT0
- --OPPORTUNITY_PRODUCT 8 ROWS
- select quantity, CALCPRICE, oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17'
- 30 1347.0000 Q6UJ9A03BDT0
- 20 1389.0000 Q6UJ9A03AGWQ
- 40 1389.0000 Q6UJ9A03AGWR
- 10 1347.0000 Q6UJ9A03B1K8
- 40 1389.0000 Q6UJ9A039OKE
- 10 1347.0000 Q6UJ9A03DCS9
- 30 1347.0000 Q6UJ9A03AKWW
- 10 1347.0000 Q6UJ9A03CEJE
- --Looking at the data in the salesorderitems table, rolloing up the products to match the oppportunity multi-quantity line:
- --There are 8 rows
- select sum(a.quantity) quantity, a.price, a.oppproductid from
- sysdba.SALESORDERITEMS a left join sysdba.C_SALESORDER b on a.SALESORDERID=b.SALESORDERID
- where a.OPPPRODUCTID in
- (select oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17')
- group by b.LEASENUM, a.OPPPRODUCTID, a.price
- 40 1389 Q6UJ9A039OKE
- 20 1389 Q6UJ9A03AGWQ
- 40 1389 Q6UJ9A03AGWR
- 30 1347 Q6UJ9A03AKWW
- 10 1347 Q6UJ9A03B1K8
- 30 1347 Q6UJ9A03BDT0
- 10 1347 Q6UJ9A03CEJE
- 10 1347 Q6UJ9A03DCS9
- --So, what is the vwExhibit SQL view???
- --It has conditions included of c_lip_Po.docoutdate is null and c_lip_po.ac is not null
- --If we look at the salesorder data again with that condition applied:
- select sum(a.quantity) quantity, a.price, a.oppproductid from
- sysdba.SALESORDERITEMS a left join sysdba.C_SALESORDER b on a.SALESORDERID=b.SALESORDERID left join
- sysdba.C_LIP_PO AS A12 ON a.SALESORDERITEMSID = A12.SALESORDERITEMSID
- where a.OPPPRODUCTID in
- (select oppproductid from sysdba.C_OPPTY_LEASEAWARD_REV where OPPORTUNITYID='O6UJ9A002BWM' and modelnumber='zbook 17')
- and
- (A12.DOCOUTDATE IS NULL) AND (A12.AC IS NOT NULL)
- group by b.LEASENUM, a.OPPPRODUCTID, a.price
- --The result is this:
- 31 1389 Q6UJ9A03AGWR
- 10 1347 Q6UJ9A03B1K8
- 10 1347 Q6UJ9A03CEJE
- 10 1347 Q6UJ9A03DCS9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement