注册 登录
编程论坛 SQL Server论坛

多条件查询的 条件选择问题 带图

shulei521521 发布于 2007-08-25 11:56, 798 次点击
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
1 回复
#2
shulei5215212007-08-25 12:01

满足这个条件 却把哪个条件查出来了 或者是满个一个大条件 只能查到大条件

1