zoukankan      html  css  js  c++  java
  • sql计算出百分比

    Code
     得到的结果是:
    level   Subtotal  total  (比例)
    中      23              86        0.267441860465
    低      26              86       0.302325581395
    高      37              86        0.430232558139

    如果a.Subtotal/b.total 则比例这一列显示为0;

    
    

    select a.level,a.Subtotal,b.total ,SUBSTRING (convert(varchar (20),(a.Subtotal*1.0/b.total*100)),1,4)+'%' as perTotal  from
    (
    select levelCOUNT(*as Subtotal from T_UserInfo where VerSionID='V20081205002' group by Level 
    )a,
    (
    select COUNT(*as total from T_UserInfo where VerSionID='V20081205002'
    最后的结果
    level Subtotal  total  perTotal  
    中      23              86        26.7%
    低      26              86       30.2%
    高      37              86        43.0%


  • 相关阅读:
    scala-隐式转换
    scala-泛型
    scala-模式匹配
    scala-LinkedList
    scala-高阶函数
    scala-数组/列表
    scala-map
    scala语法
    机器学习笔记
    Day 1 下午
  • 原文地址:https://www.cnblogs.com/z_lb/p/1553515.html
Copyright © 2011-2022 走看看