zoukankan      html  css  js  c++  java
  • SQL总结

    1.嵌套形式

    where嵌套

    select c1, c2 from table  where c3  (select c3 from table where c4 =5)

     

    from嵌套

    select a.c1, count1, count2
    from (select c1, count(c1) as count1 from table where c40 group by c1 order by c1 desc) a
        (select c1, count(c1) as count2 from table where  c1 0 and c4 1 group by c1) b
    where a.c1 = b.c1

    2.条件判断

    >,  >=,  !>,  <,  <=,  !<,  =,  !=,  <>,  in,  exist;

    (> | >= | !> | < | <= | !< | = | != | <>) + (some | all | any)

    3.计算公式

      sum(colum),  avg(colum),  count(colum) 

      max(colum),  min(colum),  union(colum)

    4.常用函数

    convert(type,  colum)  类型转换,

    abs(colum)  绝对值,

    ceiling(colum) ,ceil(colum)  取整大,

    floor(colum)  取整小,

    cast(colum) , trunc(colum)  取整、截取,

    round(colum,num)  四舍五入保留 num 位小数,

  • 相关阅读:
    POJ 1306.Combinations
    HDU 5640.King's Cake
    HDU 1072.Nightmare
    HDU 2717.Catch That Cow
    HDU 1372.Knight Moves
    HDU 1548.A strange lift
    AOJ 802.运输宝物
    AOJ 794.西瓜理发记(二)
    AOJ 793.西瓜理发记(一)
    AOJ 789.买酒
  • 原文地址:https://www.cnblogs.com/huhudollar/p/5035146.html
Copyright © 2011-2022 走看看