select 列,列*100.0/100 [占比%]
from ta

解决方案 »

  1.   

    select c,c*100/(select sum(c) from t) as 占比,identity(int,1,1) as id into # from t
    select * from #
    drop table #
      

  2.   


    CREATE TABLE A(ID int identity(1,1), col1 int)
    INSERT INTO A
    SELECT * FROM 
    (SELECT 13 AS COL1
     UNION ALL SELECT 23 AS COL1
     UNION ALL SELECT 35 AS COL1
    ) A
    ORDER BY 1SELECT * FROM A
    /*
    ID          col1
    ----------- -----------
    1           13
    2           23
    3           35(3 row(s) affected)*/