我有一个存储Order的表结构。假设我有一个订单,其中客户对每个商品要求3个Items
和不同的Qty
,每个Unit Price
不同。
店主在所有25000
上给他items
的折扣,但后来客户来了,要求从订单中删除一个item
,所以我想得到amount
的{{1}} discount
适用于该item
,因此amount
中discount
的{{1}}也适用于该订单。
item
答案 0 :(得分:4)
如果我正确理解了您的情况,则需要计算一种货币单位的折扣(25 000/450 000),然后进行所有计算:
jQuery('.feature__content__target:last-child()').hide();
jQuery('.feature__content__tabs__selector').on('click', function(e) {
var selector = jQuery(this).data('selector');
var targets = jQuery('feature__content__target');
var container = jQuery(this).closest('.feature__content');
var target = container.find('div[data-target="' + selector + '"]');
console.log(selector);
targets.removeClass('show');
target.addClass('show');
});
输出:
;
WITH cte AS (
SELECT
SALE_MASTER.ORDER_NUMBER,
SUM(SALE_DETAIL.QUANTITY * SALE_DETAIL.PRICE) AS TOTAL_AMOUNT,
SALE_MASTER.DISCOUNT_AMOUNT
FROM SALE_DETAIL, SALE_MASTER
WHERE SALE_DETAIL.ORDER_NUMBER = SALE_MASTER.ORDER_NUMBER
GROUP BY SALE_MASTER.ORDER_NUMBER, SALE_MASTER.DISCOUNT_AMOUNT
)
SELECT
SALE_DETAIL.ITEM_NAME,
SALE_DETAIL.QUANTITY,
SALE_DETAIL.PRICE,
(SALE_DETAIL.QUANTITY * SALE_DETAIL.PRICE) * (cte.DISCOUNT_AMOUNT / cte.TOTAL_AMOUNT) AS ITEM_DISCOUNT_FOR_ALL_ITEMS,
SALE_DETAIL.PRICE * (cte.DISCOUNT_AMOUNT / cte.TOTAL_AMOUNT) AS ITEM_DISCOUNT_FOR_ONE_ITEM
FROM SALE_DETAIL, cte
WHERE SALE_DETAIL.ORDER_NUMBER = cte.ORDER_NUMBER