Home > database >  SQL business problem solving!!!!!!
SQL business problem solving!!!!!!

Time:09-19


This is the effect of requirements, the following is the requirement of the TL:

I make is this:
TL glanced at said, is not he want, real income should not be take out, and the group with brackets mean, some days not to sell these items
Cook for two days, haven't been done, the great god guide [please]

CodePudding user response:

Suggest you list the table structure, and provide test data and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,
Refer to the way the post questions at http://bbs.csdn.net/topics/320211382

CodePudding user response:

Link: https://pan.baidu.com/s/1 - b3u - IKshWg4tykiisUag extraction code: vbaa this is a database file

CodePudding user response:

SELECT
Ims_wcy_order_item item_type_name1 AS 'classification,
The sum (ims_wcy_order_item. Item_price * ims_wcy_order_item. Item_count) AS 'the sales amount,
IFNULL (sum (ims_wcy_order_give_item. ITEM_PRICE * ims_wcy_order_give_item. ITEM_COUNT), 0) AS 'amount donated food,
IFNULL (sum (- ims_wcy_order_return_item. Item_price * ims_wcy_order_return_item. Item_count), 0) AS 'food amount back,
CASE
The WHEN ims_wcy_order_item. Order_id=ims_wcy_order_dis. Order_id THEN
The sum (ims_wcy_order_item. Item_price * ims_wcy_order_item. Item_count) * ims_wcy_order_dis discount ELSE sum (ims_wcy_order_item. Item_price * ims_wcy_order_item. Item_count)
END AS 'paid-in amount,
The sum (ims_wcy_order_item. Item_price * ims_wcy_order_item. Item_count) - the sum (ims_wcy_order_item. Item_price * ims_wcy_order_item. Item_count) * ims_wcy_order_dis discount AS 'discount amount'
The FROM
Ims_wcy_mst_item_type
LEFT the JOIN ims_wcy_order_item ON ims_wcy_order_item. Item_type_code=ims_wcy_mst_item_type. Item_type_code
LEFT the JOIN ims_wcy_order_dis ON ims_wcy_order_item. Order_id=ims_wcy_order_dis. Order_id
LEFT the JOIN ims_wcy_order_give_item ON ims_wcy_order_item. Order_id=ims_wcy_order_give_item. Order_id
LEFT the JOIN ims_wcy_order_return_item ON ims_wcy_order_return_item. Order_id=ims_wcy_order_item. Order_id
WHERE
Ims_wcy_order_item. Weid=ims_wcy_mst_item_type. Weid
GROUP BY
Ims_wcy_mst_item_type. Item_type_name1
The ORDER BY
Ims_wcy_mst_item_type. Item_type_name1

CodePudding user response:


I'm sorry, just put the wrong figure

CodePudding user response:

The Target Server Type: MySQL====& gt; Advice to turn MySQL version of the question.
  • Related