If I've understood your question correctly, and assuming your price-bands are well defined
(no overlaps or gaps), then something like this should work:
WITH prices As
(
SELECT
l.licence_companyid,
l.licence_productid,
l.licence_quantity,
b.pricing_price,
b.pricing_price * l.licence_quantity As company_cost
FROM
licence As l
INNER JOIN price_banding As b
ON b.pricing_productid = l.licence_productid
WHERE
b.pricing_stepped = 0
And
b.pricing_band_min <= l.licence_quantity
And
(b.pricing_band_max >= l.licence_quantity Or b.pricing_band_max Is Null)
UNION ALL
SELECT
l.licence_companyid,
l.licence_productid,
Max(l.licence_quantity),
Max(b.pricing_price),
Sum(b.pricing_price * CASE
WHEN b.pricing_band_max Is Null THEN 1 + l.licence_quantity - b.pricing_band_min
WHEN b.pricing_band_max >= l.licence_quantity THEN 1 + l.licence_quantity - b.pricing_band_min
ELSE 1 + b.pricing_band_max - b.pricing_band_min
END)
FROM
licence As l
INNER JOIN price_banding As b
ON b.pricing_productid = l.licence_productid
WHERE
b.pricing_stepped = 1
And
b.pricing_band_min <= l.licence_quantity
GROUP BY
l.licence_companyid,
l.licence_productid
)
SELECT
c.company_id,
c.company_name,
b.pricing_price,
p.product_name,
b.licence_quantity,
b.company_cost
FROM
prices As b
INNER JOIN company As c
ON c.company_id = b.licence_companyid
INNER JOIN product As p
ON p.product_id = b.licence_productid
;
If that's not right, can you create a
SQL Fiddle[
^] with some dummy sample data to demonstrate?