zoukankan      html  css  js  c++  java
  • 统一单位并计算采购面积

     1 select  
     2     mass,
     3     case when unit like '英寸%' then '英寸'
     4     when unit like '厘米%' then '厘米' 
     5 when unit = '米%' then ''
     6 when unit = '毫米%' then '毫米'
     7 end unit
     8 ,
     9 round (sum (
    10     convert( float,
    11         case when  unit like '厘米%' then convert (varchar(20),(leng*0.01)*(wide * 0.01)*qty)
    12         when unit like '英寸%' then convert(varchar(20),(leng*0.0254)*(wide * 0.0254)*qty)
    13         when unit = '米%' then convert (varchar(20),leng*wide)
    14         when unit = '毫米%' then convert (varchar(20),(leng*0.001)*(wide * 0.001)*qty)
    15         end 
    16     )
    17 ) * 1.550031 ,3)AS  采购面积
    18 
    19 from CaiGouXinXi
    20 where leng >0 and wide > 0 
    21 group by mass,unit
    22 order by 采购面积 desc
     1  1 select  
     2  2     mass,
     3  3     case when unit like '英寸%' then '英寸'
     4  4     when unit like '厘米%' then '厘米' 
     5  5 when unit = '米%' then ''
     6  6 when unit = '毫米%' then '毫米'
     7  7 end unit
     8  8 ,
     9  9 round (sum (
    10 10     convert( float,
    11 11         case when  unit like '厘米%' then convert (varchar(20),(leng*0.01)*(wide * 0.01)*qty)
    12 12         when unit like '英寸%' then convert(varchar(20),(leng*0.0254)*(wide * 0.0254)*qty)
    13 13         when unit = '米%' then convert (varchar(20),leng*wide)
    14 14         when unit = '毫米%' then convert (varchar(20),(leng*0.001)*(wide * 0.001)*qty)
    15 15         end 
    16 16     )
    17 17 ) ,3)AS  采购面积
    18 18 
    19 19 from CaiGouXinXi
    20 20 where leng >0 and wide > 0 
    21 21 group by mass,unit
    22 22 order by 采购面积 desc

    表中部分字段:  leng wide qty unit mass

    查询结果,如下图所示。

  • 相关阅读:
    验证码处理 -- 爬虫
    Django知识点总结
    关于sql去重
    tsxt-01
    崔老师爬取top100的源码(会403)
    简单爬取网页源码
    爬取猫眼top100
    python-自动发邮件
    python-装饰器
    Python 爬虫基础Selenium库的使用
  • 原文地址:https://www.cnblogs.com/bamboo-140/p/9510397.html
Copyright © 2011-2022 走看看