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");具體就是想實現這樣一個功能.但現在語句有問題,,,
高手請支招

解决方案 »

  1.   

    楼主为何不分开用两条语句?
    第一条增加一个列,
    第二条用case语句去update此列~~~
      

  2.   

     "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编过了
      

  3.   

    我暈...
    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编过了的
      

  4.   


    这样好看些
    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"); 
      

  5.   


    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")