- 已关闭。**此问题为not reproducible or was caused by typos。当前不接受答案。
这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
两年前关闭了。
此帖子已在2天前编辑并提交审核,无法重新打开帖子:
原始关闭原因未解决
Improve this question
这种方法实际上在C#中有效,但在SQL Server中执行时不起作用:
Select
t3.MNAME + cast(t3.N as nvarchar) as 'کد دسته بندي',
t3.NAME as 'شرح دسته',
sum(case when t1.DT = 1 then t1.N1 - t1.N2 else 0 end) as 'خريد',
sum(case when t1.DT = 8 then t1.N1 - t1.N2 else 0 end) as 'برگشت خريد',
'' as 'حواله شعب',
'' as 'برگشت شعب',
'' as 'فروش',
sum(case when t1.DT = 9 then t1.N1 - t1.N2 else 0 end) as 'برگشت فروش',
sum(case when t1.DT = 10 then t1.N1 - t1.N2 else 0 end) as 'ت کاردکس',
sum(N1 - N2) as 'موجودي',
sum(case when t1.DT = 4 then t1.N1 - t1.N2 else 0 end) as 'ح شعب',
sum(case when t1.DT = 5 then t1.N1 - t1.N2 else 0 end) as 'ح ت شعب',
sum(case when t1.DT = 6 then t1.N1 - t1.N2 else 0 end) as 'ب شعب',
sum(case when t1.DT = 7 then t1.N1 - t1.N2 else 0 end) as 'ب ت شعب',
sum(case when t1.DT = 2 then t1.N1 - t1.N2 else 0 end) as 'ح ت فروش',
sum(case when t1.DT = 3 then t1.N1 - t1.N2 else 0 end) as 'فروش جزئي',
sum(case when t1.DT = 12 then t1.N1 - t1.N2 else 0 end) as 'فروش عادي',
sum(case when t1.DT = 11 then t1.N1 - t1.N2 else 0 end) as 'برگشت فروش تعدادي'
From
BC as t1, _TBS_TYPE as t3
Where
substring(t1.BARCODE, 1, 1) = t3.MNAME
and substring(t1.BARCODE, 2, 1) = cast(t3.N as nvarchar)
and t3.MNAME + cast(t3.N as nvarchar) and t3.NAME
group by
t3.MNAME, t3.N, t3.NAME
order by
2, 3
错误:
在需要条件的上下文中指定的非布尔类型的表达式,靠近"and"。
2条答案
按热度按时间mlmc2os51#
尝试下面的方法-在不指定任何值的情况下,定义一个类似于-
and t3.MNAME + cast(t3.N as nvarchar) and t3.NAME
的条件此外,最好使用显式
JOIN
disho6za2#
在Where条件筛选器中,代码中缺少值的右侧。