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

  • 相关阅读:
    Android Studio --“Cannot resolve symbol” 解决办法
    js与android webview交互
    关于post与get请求参数存在特殊字符问题
    Fragment 学习笔记(1)
    Android Studio 错误集
    UVA
    UVA
    UVALive
    考试题string——线段树。
    洛谷 1552 [APIO2012]派遣
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8311048.html
Copyright © 2011-2022 走看看