Sample Query to fetch Pricing per Customer with itemtype and Customer ID as filter

SELECT 
    BUILTIN_RESULT.TYPE_INTEGER(pricingWithCustomers.internalid) AS internalid,  
    BUILTIN_RESULT.TYPE_PERCENT(priceLevel.discountpct) AS discountpct,
    BUILTIN_RESULT.TYPE_CURRENCY(pricingWithCustomers.unitprice, BUILTIN.CURRENCY(pricingWithCustomers.unitprice)) AS netprice
    
FROM 
    pricingWithCustomers
LEFT JOIN 
    item ON pricingWithCustomers.item = item.ID
LEFT JOIN 
    priceLevel ON pricingWithCustomers.pricelevel = priceLevel.ID
LEFT JOIN 
    Customer ON pricingWithCustomers.customer = Customer.ID
WHERE 
    (
        item.itemtype = 'Service' 
        OR BUILTIN.DF(pricingWithCustomers.quantity) = 0
    )
    AND pricingWithCustomers.assignedpricelevel = 'T' 
    AND item.isinactive = 'F' 
    AND item.itemtype IN (${idPlaceholders})
    AND priceLevel.isinactive = 'F'
    AND Customer.ID = ?

Leave a comment

Your email address will not be published. Required fields are marked *