久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

mysql怎么實現的lead和lag函數功能

139次閱讀
沒有評論

共計 2325 個字符,預計需要花費 6 分鐘才能閱讀完成。

本篇內容主要講解“mysql 怎么實現的 lead 和 lag 函數功能”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“mysql 怎么實現的 lead 和 lag 函數功能”吧!

MariaDB [test] select * from t;
+————————————–+———————+
| case_id                              | assigned_date       |
+————————————–+———————+
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-18 14:08:14 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d51 | 2016-05-18 14:25:22 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-18 14:26:01 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 07:19:13 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 07:53:09 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d51 | 2016-05-19 08:18:01 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 12:12:35 |
+————————————–+———————+
7 rows in set (0.00 sec)
MariaDB [test] SELECT t1.case_id, t1.assigned_date,
    –        (SELECT t2.assigned_date
    –        FROM t AS t2
    –        WHERE t2.case_id = t1.case_id AND
    –              t2.assigned_date t1.assigned_date
    –        ORDER BY t2.assigned_date LIMIT 1) AS next_date,
    –        (SELECT t2.assigned_date
    –        FROM t AS t2
    –        WHERE t2.case_id = t1.case_id AND
    –              t2.assigned_date t1.assigned_date
    –        ORDER BY t2.assigned_date DESC LIMIT 1) AS prev_date
    – FROM t AS t1;
+————————————–+———————+———————+———————+
| case_id                              | assigned_date       | next_date           | prev_date           |
+————————————–+———————+———————+———————+
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-18 14:08:14 | 2016-05-18 14:26:01 | NULL                |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d51 | 2016-05-18 14:25:22 | 2016-05-19 08:18:01 | NULL                |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-18 14:26:01 | 2016-05-19 07:19:13 | 2016-05-18 14:08:14 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 07:19:13 | 2016-05-19 07:53:09 | 2016-05-18 14:26:01 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 07:53:09 | 2016-05-19 12:12:35 | 2016-05-19 07:19:13 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d51 | 2016-05-19 08:18:01 | NULL                | 2016-05-18 14:25:22 |
| 41c19f76-e52e-c4c9-62c2-573c71ec5d50 | 2016-05-19 12:12:35 | NULL                | 2016-05-19 07:53:09 |
+————————————–+———————+———————+———————+
7 rows in set (0.01 sec)

到此,相信大家對“mysql 怎么實現的 lead 和 lag 函數功能”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-03發表,共計2325字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 湄潭县| 保山市| 松江区| 大田县| 澄迈县| 柳江县| 团风县| 太仓市| 黄大仙区| 射洪县| 霍州市| 佛坪县| 嵊州市| 西昌市| 伊通| 金坛市| 济阳县| 崇信县| 积石山| 西乌珠穆沁旗| 乳源| 阿拉尔市| 涿鹿县| 如皋市| 宁陕县| 临洮县| 城口县| 泸州市| 明溪县| 乌审旗| 河池市| 莒南县| 栾城县| 延安市| 商丘市| 高邮市| 泾阳县| 上饶县| 安西县| 塔城市| 赣州市|