zoukankan      html  css  js  c++  java
  • MYSQL基础ORDER BY关键字 / GROUP BY关键字/ GROUP_CONCAT()函数 / COUNT()函数 / HAVING 关键字 / WITH ROLLUP关键字 / LIMIT关键字

    『1』对查询结果进行排序(默认是按照Asc排序方式排序)

      select * from employee order by age;

      

    『2』对查询结果进行Eesc排序

      select * from employee order by age desc;

      

    『3』多次排序

      select * from employee order by d_id asc,age asc;

      

    『4』order by和group_concat函数连用

      select sex,group_concat(name) from employee group by sex;

      

    『5』GROUP BY 关键字与COUNT()函数连用

      select sex,count(sex) from employee group by sex;

      

    『6』GROUP BY关键与HAVING一起使用

      select sex,count(sex) from employee group by sex having count(sex)>=3;

      

    『7』GROUP BY 关键字与WITH ROLLUP一起使用

      select sex,count(sex) from employee group by sex with rollup; (在输出最后一行做数据统计)

      

    『8』LIMIT关键字

      select * from employee limit 0,3;(从0开始一共3行)

      

  • 相关阅读:
    第09组 Alpha冲刺 (2/6)
    第08组 Beta冲刺 (1/5)
    第08组 Alpha冲刺 总结
    第08组 Alpha冲刺 (6/6)
    第08组Alpha冲刺(5/6)
    第08组 Alpha冲刺 (4/6)
    第08组 Alpha冲刺 (3/6)
    第08组 Alpha冲刺 (2/6)
    第08组 Alpha冲刺 (1/6)
    第12组 Beta冲刺(2/5)
  • 原文地址:https://www.cnblogs.com/DeepBlues/p/2994516.html
Copyright © 2011-2022 走看看