ds.Tables["Differences"].Columns.Add("Ping", typeof(decimal),
"CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))<0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END AS Ping");
具體就是想實現這樣一個功能.但現在語句有問題,,,
高手請支招
...全文
16711打赏收藏
很簡單的一個問題
ds.Tables["Differences"].Columns.Add("Ping", typeof(decimal), "CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))<0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END AS Ping"); 具體就是想實現這樣一個功能.但現在語句有問題,,, 高手請支招
[Quote=引用 8 楼 zzxap 的回复:]
SQL code
CASE WHEN ( cast(isnull(Yuliu,0) as int )+ cast(isnull(Sent,0) as int)+cast(isnull(Amount,0) as int)) <0 THEN ABS(( cast(isnull(Yuliu,0) as int )+ cast(isnull(Sent,0) as int)+cast(isnull(Amount,0) as int))) ELSE 0 END AS Ping")
[/Quote]
[code=SQL]
CASE WHEN ( cast(isnull(Yuliu,0) as int )+ cast(isnull(Sent,0) as int)+cast(isnull(Amount,0) as int)) <0 THEN ABS(( cast(isnull(Yuliu,0) as int )+ cast(isnull(Sent,0) as int)+cast(isnull(Amount,0) as int))) ELSE 0 END AS Ping")
[code=SQL]
这样好看些
ds.Tables["Differences"].Columns.Add("Ping", typeof(decimal),
"CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0)) <0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END AS Ping");
[Quote=引用 3 楼 wanabe 的回复:]
"CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0)) <0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END AS Ping"
else用来干嘛的,语句根本就不完整啊,建议到查询分析器里面建个跟ds.Tables["Differences"]一样的表,先吧sql编过了
[/Quote]
我暈...
CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0)) <0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END
我暈...else用來判斷反之的啊
這句難道有錯...
我sql编过了的
"CASE WHEN((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0)) <0) THEN ABS((isnull(Yuliu,0)+isnull(Sent,0)+isnull(Amount,0))) ELSE 0 END AS Ping"
else用来干嘛的,语句根本就不完整啊,建议到查询分析器里面建个跟ds.Tables["Differences"]一样的表,先吧sql编过了