SQL大师帮看看where条件“通道”=‘A’失效,汇总的结果还是全部数据??咋回事??
代码如下,我是编写在asp里面的
SELECT ISNULL(备货编号, '合计') AS 备货编号, ISNULL(备件名称, '汇总') AS 备件名称,
备货单号, SUM(箱数YES) AS 备货数量, ISNULL(网点, '') AS 网点, COUNT(*)
AS 发货件数
FROM ktjj
WHERE (CONVERT(varchar(10), 扫描时间, 120) BETWEEN '2012-06-18' AND
'2012-06-18') AND (备货编号 LIKE 'ka%') OR
(备货编号 LIKE 'xt%') AND (通道 = 'A')
GROUP BY 备货编号, 备件名称, 备货单号, 网点 WITH rollup
HAVING (grouping(备货编号) = 1) OR
(grouping(备件名称) = 1) OR
(grouping(网点) = 0) AND (grouping(备货单号) = 0)
where条件“通道”=‘A’失效,汇总的结果还是全部数据,并且里面包含了其他的通道C和B的都有??咋回事??望高手解答??非常感激!呵呵