limit后面可跟一个参数或2个参数。2个参数是从第几行开往下边几行

排序:

    select * from tb order by id desc; 从大到小

                                                 asc; 从小到大

               列1 desc , 列2 asc;   先按列1排,重复了按列2排

分组:

    

      select count(id),max(id),part_id from userinfo5 group by part_id;

        count:计数
        max:取最大
        min:最小
        sum:求和
        avg:平均值    

    **** 如果对于聚合函数结果进行二次筛选时?必须使用having ****
    select count(id),part_id from userinfo5 group by part_id having count(id) > 1;

   

posted on 2018-07-06 17:18  lxltxdy  阅读(61)  评论(0)    收藏  举报