我已經在YTD(迄今),QTD(季度到日期)和MTD(月迄今)的基礎上顯示總產品銷售。事情是我必須從那些只顯示一個。在選擇的基礎上只能看到一個輸出,就像我們有單選按鈕可以從衆多選項中選擇一個。這裏也給出一個輸入來選擇,並根據該輸入生成輸出。輸入可以是任何YTD,QTD或MTD。輸出是基於輸入生成的。我不知道如何計算一個輸出可以變化的列輸出。 我有一個產品表-1一列計算多個輸出
Product_ID Product_name Price
1 Mobile 200
2 T.V. 400
3 Mixer 300
我有一個Sales表像這個 -
Product_ID Sales_Date Quantity
1 01-01-2015 30
2 03-01-2015 40
3 06-02-2015 10
1 22-03-2015 30
2 09-04-2015 10
3 21-05-2015 40
1 04-06-2015 40
2 29-07-2015 30
1 31-08-2015 30
3 14-09-2015 30
而且我的輸出中列包含3列是爲─ Product_id, Product_Name and Total_Amount
。 列TOTAL_AMOUNT(數量*價格)要計算出售用戶即給定輸入的基礎上,
IF it is YTD then it should calculate the total sale from Starting Date of Year (01-01-2015) to the current_date(sysdate),
IF it is QTD then in which quarter the current date is falling i.e if current month is september then from 1 July to current_date(sysdate),
IF it is MTD then in which month the current date is falling to the current_date(sysdate).
誰能幫助。謝謝!!!
該查詢不詢問應該計算哪個product_id(它只是計算 –
對不起,我忘了加入產品;腳本已被修改,再加上價格已乘以 – ridi
是的,它工作:)謝謝! ! –