zoukankan      html  css  js  c++  java
  • 4、SQL基础整理(规范函数)

    规范函数:

    绝对值

    select abs(-5)

    print abs(-5)

    表中取绝对值的方法:

    select code,name,abs(chinese)as yuwen from xuesheng

    select *from xuesheng where ABS(chinese)>90

    天花板、地板

    select ceiling(math) from xuesheng//天花板

    select *from xuesheng where ([weight] - CEILING([weight]))!=0

    几次幂

    select POWER(3,2) --表示的次方等于几就返回几

     

    select POWER(age,2)from xuesheng

     

    select '这是'+name+'的年龄的平方',POWER(age,2)from xuesheng

    四舍五入

    select ROUND(176.2,0)///逗号前表示要四舍五入的数,逗号后表示要四舍五入到小数点后几位。

    select [weight],ROUND([weight],0) as shehou from xuesheng

    开方(平方根)

    select SQRT(4)//结果为2

    select SQUARE(4)//结果为16

     

    行列颠倒函数(PIVOT)

    select * from 表名
    PIVOT (
    聚合函数的类型(想要查询的列名) for 需要颠倒的列名 IN (需要颠倒的列中所含的值--用来作为新列名)
    ) as p

  • 相关阅读:
    ubuntu 1804 docker install
    windows shortcut
    gallary
    g++ play
    linux profile
    terminator
    tmux
    ubuntu18
    windows toolkit
    windows terminal CLI
  • 原文地址:https://www.cnblogs.com/wleaves/p/4164983.html
Copyright © 2011-2022 走看看