zoukankan      html  css  js  c++  java
  • mysql group by 组内排序 group by 原理

    mysql group by 组内排序

     

    SELECT * FROM (
    SELECT MAX(id) AS t,wukong_uid, 1 AS tag FROM  toutiao_uid_gathered_wukong GROUP BY wukong_uid
    UNION ALL
    SELECT id AS t ,wukong_uid, 2 AS tag FROM toutiao_uid_gathered_wukong
    ) AS tab ORDER BY wukong_uid ASC , t ASC ;

    验证group by原理 是否来源同一行数据

    SELECT * FROM (
    SELECT MAX(id) AS t,wukong_uid, 1 AS tag,time_script FROM xmt_star_helper_toutiao_uid_gathered_wukong GROUP BY wukong_uid
    UNION ALL
    SELECT id AS t ,wukong_uid, 2 AS tag,time_script FROM xmt_star_helper_toutiao_uid_gathered_wukong
    ) AS tab ORDER BY wukong_uid ASC , t ASC ;

    5914 10301285240 2 1516248413
    6563 10301285240 2 1516264338
    6767 10301285240 2 1516264338
    7774 10301285240 2 1516264338
    7774 10301285240 1 1516193381
    376 10499564112 2 1516193381
    4565 10499564112 2 1516248413
    5019 10499564112 2 1516248413
    5534 10499564112 2 1516248413
    6425 10499564112 2 1516264338
    6879 10499564112 2 1516264338
    7394 10499564112 2 1516264338
    7977 10499564112 2 1516264338
    7977 10499564112 1 1516193381
    360 10818489841 2 1516193381
    360 10818489841 1 1516193381

  • 相关阅读:
    leetcode回溯总结
    排序算法详解
    Java核心基础知识泛型
    leetcode贪心算法
    Linux虚拟机配置及安装Redis
    HJ6质数因子
    冒泡排序(升序)
    动态规划 背包问题
    配置mycatschema.xml
    HJ106字符逆序
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8311048.html
Copyright © 2011-2022 走看看