select * from test where trxcode = '2123' 有结果吗?select * from test where trxcode = '2123' and isnull(amout1,0) > 0 有结果吗?select * from test where trxcode = '2123' and isnull(abs(amout1),0) > 0 有结果吗?

解决方案 »

  1.   

    select * from test where trxcode = '2123' 没有结果?
    但是我的表中绝对有数据的,
    是不是"trxcode=2123"不成立?
      

  2.   

    select * from test where trxcode = '2123'
      

  3.   

    那是因為你將 trxcode 定義為money型.
    money型是有固定長度的.你可能定義為五位
    而 '2123'是字符型.'2123'<>' 2123'
      

  4.   

    我看了一下我的表的设计,
    发现tracode nvarchar 50
        amount1  money 8
      

  5.   

    SELECT draccno, SUM(CASE WHEN ltrim(rtrim(trxcode)) = '2123' THEN amount1 ELSE 0 END) 
          AS abc
    FROM test
    GROUP BY draccno
      

  6.   

    SELECT draccno, SUM(CASE WHEN ltrim(rtrim(trxcode)) = '2123' THEN isnull(amount1,0) ELSE 0 END) 
          AS abc
    FROM test
    GROUP BY draccno