多条件查询的 条件选择问题 带图
SELECT SUM(T_Goods_Day_Sale.inprc * T_Goods_Day_Sale.qty) AS chengben, SUM(T_Goods_Day_Sale.ramt) AS ramt, SUM(T_Goods_Day_Sale.ramt)
- SUM(T_Goods_Day_Sale.inprc * T_Goods_Day_Sale.qty) AS maoli,
(SUM(T_Goods_Day_Sale.ramt)
- SUM(T_Goods_Day_Sale.inprc * T_Goods_Day_Sale.qty))
/ SUM(T_Goods_Day_Sale.ramt) * 100 AS maolilv,
T_Goods_Day_Sale.sale_date
FROM T_Goods_Day_Sale INNER JOIN
T_Store ON T_Goods_Day_Sale.store_id = T_Store.store_id
WHERE (T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.store_type = @store_type OR
@store_type IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.store_type = @store_type OR
@store_type IS NULL) AND (T_Store.store_name = @store_name OR
@store_name IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.store_name = @store_name OR
@store_name IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.area = @area OR
@area IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.store_type = @store_type OR
@store_type IS NULL) AND (T_Store.area = @area OR
@area IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL) AND (T_Store.store_type = @store_type OR
@store_type IS NULL) AND (T_Store.store_name = @store_name OR
@store_name IS NULL) AND (T_Store.area = @area OR
@area IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.area = @area OR
@area IS NULL) OR
(T_Goods_Day_Sale.sale_date BETWEEN @dateB AND @dateE) AND
(T_Store.Mgr_id = @mgr_id OR
@mgr_id IS NULL)
GROUP BY T_Goods_Day_Sale.sale_date