很簡單的一個問題

wwwiii520 2009-03-09 10:11:09
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");

具體就是想實現這樣一個功能.但現在語句有問題,,,
高手請支招
...全文
167 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwiii520 2009-03-10
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 zzxap 的回复:]
防止你的字段是非int类型,
[/Quote]
還是沒用啊.
zzxap 2009-03-10
  • 打赏
  • 举报
回复
防止你的字段是非int类型,
wwwiii520 2009-03-09
  • 打赏
  • 举报
回复
[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]

為什麼要這樣??能說說嘛?
zzxap 2009-03-09
  • 打赏
  • 举报
回复
[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]
wwwiii520 2009-03-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zzxap 的回复:]
SQL code
这样好看些
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]

是的..可是這樣有問題啊
wwwiii520 2009-03-09
  • 打赏
  • 举报
回复
zzxap 2009-03-09
  • 打赏
  • 举报
回复
[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");

[/CODE]
wwwiii520 2009-03-09
  • 打赏
  • 举报
回复
[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编过了的
wanabe 2009-03-09
  • 打赏
  • 举报
回复
"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编过了
wwwiii520 2009-03-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yygyogfny 的回复:]
楼主为何不分开用两条语句?
第一条增加一个列,
第二条用case语句去update此列~~~
[/Quote]

不知道你想怎麼實現??
yygyogfny 2009-03-09
  • 打赏
  • 举报
回复
楼主为何不分开用两条语句?
第一条增加一个列,
第二条用case语句去update此列~~~

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧