sign db_username db_ip beginTime endTime
downloadFiles tom 125.92.142.224 1378063471 1378063472
downloadFiles tom 125.92.142.224 1378072128 1378072129
downloadFiles tom2 84.14.196.239 1378077892 1378077893
downloadFiles tom2 84.14.196.239 1378077893 1378077894
downloadFiles tom2 84.14.196.239 1378077894 1378077895
downloadFiles tom2 84.14.196.239 1378077895 1378077896
downloadFiles tom2 84.14.196.239 1378077896 1378077897
downloadFiles tom2 84.14.196.239 1378077897 1378077898
downloadFiles tom2 84.14.196.239 1378079181 1378079182
downloadFiles tom2 84.14.196.239 1378079181 1378079182
downloadFiles tom2 84.14.196.239 1378079182 1378079183
downloadFiles tom2 84.14.196.239 1378079182 1378079183
downloadFiles tom2 84.14.196.239 1378079184 1378079185
downloadFiles tom2 84.14.196.239 1378079184 1378079185
downloadFiles tom2 84.14.196.239 1378079184 1378079185
downloadFiles tom2 84.14.196.239 1378079185 1378079186
downloadFiles tom2 84.14.196.239 1378079185 1378079186
downloadFiles tom2 84.14.196.239 1378079185 1378079186
downloadFiles tom2 84.14.196.239 1378079188 1378079189
downloadFiles tom2 84.14.196.239 1378079188 1378079189
downloadFiles tom2 84.14.196.239 1378079189 1378079190
downloadFiles tom2 84.14.196.239 1378079190 1378079191
downloadFiles tom2 84.14.196.239 1378079190 1378079191
downloadFiles tom2 84.14.196.239 1378079191 1378079192
downloadFiles tom2 84.14.196.239 1378079192 1378079193
我數(shù)據(jù)庫里有這樣的數(shù)據(jù)(關(guān)于時間值,我己轉(zhuǎn)為unix 時間戳,方便比較) 想將各個用戶的時間段總和求出來 聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
現(xiàn)在我想要查詢一個用戶不重復(fù)的時間段的總和(如有重復(fù)的時間段,不計入總和,只計一次)
如 tom 第一條 為 2013-09-11 18:22:34 as T1 2013-09-11 18:22:54 as T2
第二條 為 2013-09-11 18:23:34 as T3 2013-09-11 18:24:54 as T4
SUM=(T2-T1)+(T4-T3) boz T3>T2
如果 第二條 為 2013-09-11 18:24:00 as T3 2013-09-11 18:24:54 as T4
SUM=(T4-T1) boz T3T1
如果 第二條 為 2013-09-11 18:22:37 as T3 2013-09-11 18:22:50 as T4
sum=T2-T1 boz T3
結(jié)果集為
downloadFiles tom 125.92.142.224 TotalTime 15(seconds)
downloadFiles tom2 84.14.196.239 TotalTime 309(seconds)
分組為sign/username/ip