zoukankan      html  css  js  c++  java
  • 计算字段

    1,常量字段

     select 'CowNew集团',918000000 as 注册资金,* from T_Employee
    其中 'CowNew集团',918000000 并不是实际的列, 这样的字段称为‘常量字段’,常量字段也可以看成普通的字段

    2,字段间的计算

    例子:计算员工工资指数公式为:薪水*年龄

       select FSalary* Fage as 工资指数 ,* from T_Employee  FSalary* Fage可以被看成一个普通的字段,与其他的字段间进行计算

       select 125+521 as 和, FSalary/(FAge-21)as 幸福指数, * from T_Employee  

       select * from T_Employee where FSalary/(FAge-21)>1000

    计算字段可以在where update delete 等语句中使用

    3,数据处理函数

    计算字符长度函数:oracle,mysql,db2 中是:length  sql server中是:len

    select LEN (FName)as 长度,FName  from T_Employee where FName is not null

    取字符串子串的函数:mysql,sql server 中是:substring , oracle,db2中是:substr

    select SUBSTRING(Fname,1,2),FName from T_Employee

    正弦函数:sin 绝对值函数:abs

    select  SIN (FAge),ABS(FAge),FAge,FName from T_Employee

  • 相关阅读:
    CentOS/RHEL 查看用户登陆信息
    PAM
    块存储
    ECS
    SQL 基础应用
    MySQL 基础管理
    MySQL 体系结构
    JSON对象
    设置dom节点属性的代码优化
    Ext框架下的元素拖动
  • 原文地址:https://www.cnblogs.com/lucky9/p/6268578.html
Copyright © 2011-2022 走看看