select A,sum(ASCII(LOWER(B))-96) as C from 表

解决方案 »

  1.   

    select A,sum(ASCII(LOWER(B))-96) as C from 表 group by A
      

  2.   

    当值为'a,则Select出来后值为'1'
        当值为'b',则Select出来后值为'2'
        当值为'c',则Select出来后值为'3'
        当值为'd',则Select出来后值为'4'
     ....
    这些条件也实现了吗?
      

  3.   

    ASCII(LOWER(B))-96
    这是什么意思?
      

  4.   

    agree with libin_ftsafe(子陌红尘)
      

  5.   

    Transact-SQL 参考  
    ASCII
    返回字符表达式最左端字符的 ASCII 代码值。语法
    ASCII ( character_expression ) 参数
    character_expression是类型为 char 或 varchar的表达式。返回类型
    int示例
    下例假定在 ASCII 字符集环境下运行,它将返回字符串"Du Monde entier"中每一个字符的 ASCII 值和 char 字符。SET TEXTSIZE 0
    SET NOCOUNT ON
    -- Create the variables for the current character string position 
    -- and for the character string.
    DECLARE @position int, @string char(15)
    -- Initialize the variables.
    SET @position = 1
    SET @string = 'Du monde entier'
    WHILE @position <= DATALENGTH(@string)
       BEGIN
       SELECT ASCII(SUBSTRING(@string, @position, 1)),
          CHAR(ASCII(SUBSTRING(@string, @position, 1)))
        SET @position = @position + 1
       END
    SET NOCOUNT OFF
    GO下面是结果集:----------- - 
    68          D 
                  
    ----------- - 
    117         u 
                  
    ----------- - 
    32            
                  
    ----------- - 
    109         m 
                  
    ----------- - 
    111         o 
                  
    ----------- - 
    110         n 
                  
    ----------- - 
    100         d 
                  
    ----------- - 
    101         e 
                  
    ----------- - 
    32            
                  
    ----------- - 
    101         e 
                  
    ----------- - 
    110         n 
                  
    ----------- - 
    116         t 
                  
    ----------- - 
    105         i 
                  
    ----------- - 
    101         e 
                  
    ----------- - 
    114         r
    请参见字符串函数&copy;1988-2000 Microsoft Corporation。保留所有权利。
      

  6.   

    a,b,c,d 只是你简写?
    select A,sum(B) as C from 表 group by A
      

  7.   

    对,只是简写,我要统计一个调查结果并评分
    bad......2
    poor.......4
    fair......6
    good.....8
    very good....10
    然后再统计
      

  8.   

    我用SELECT case B
              when 'poor' then '2'
              when 'fair' then '4'                
              when 'good' then '6'  
              when 'verygood' then '8'  
              when 'excellent' then '10'  
           end as C
    这样可以得出每题的分数,如何把这些分数加起来