SQL语句求解同一人物不同日期,某一属性的差值
生活随笔
收集整理的這篇文章主要介紹了
SQL语句求解同一人物不同日期,某一属性的差值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
表格如下,只有三列,第一列代表用戶id,第二列代表日期,第三列代表在該日期朋友數量
例一:找到所有12月2號朋友數量增加的用戶
SELECT table1.user_id ,ta.friend_count as day1 , table1.friend_count as daya2 FROM table1 INNER JOIN table1 as ta on table1.user_id = ta.user_id and table1.date='12/2/2015' and table1.friend_count>ta.friend_count?
?
例二:找到12月2號朋友數量增加最多的用戶
SELECT table1.user_id ,ta.friend_count as day1 , table1.friend_count as daya2 , table1.friend_count-ta.friend_count as add_num FROM table1 INNER JOIN table1 as ta on table1.user_id = ta.user_id and table1.date='12/2/2015' and table1.friend_count-ta.friend_count >0 ORDER BY add_num DESC?
總結
以上是生活随笔為你收集整理的SQL语句求解同一人物不同日期,某一属性的差值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自动完形填空系统构建
- 下一篇: python开源聊天机器人Chatter