本帖最後由 yku 於 2023-2-8 11:05 AM 編輯
- select sum(ret2.a4) as sum_tot
- from(
- select ret.*
- from (
- select '2022/11/17' as a1,'00:03' as a2,'keyboard' as a3,'88' as a4 union all
- select '2022/11/17' as a1,'00:03' as a2,'mouse' as a3,'77' as a4 union all
- select '2022/11/17' as a1,'00:03' as a2,'trumpet' as a3,'66' as a4 union all
- select '2022/11/17' as a1,'00:03' as a2,'screen' as a3,'55' as a4 union all
- select '2022/11/17' as a1,'00:20' as a2,'keyboard' as a3,'99' as a4 union all
- select '2022/11/17' as a1,'00:20' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/17' as a1,'00:20' as a2,'trumpet' as a3,'55' as a4 union all
- select '2022/11/17' as a1,'00:20' as a2,'screen' as a3,'33' as a4 union all
- select '2022/11/17' as a1,'00:40' as a2,'keyboard' as a3,'22' as a4 union all
- select '2022/11/17' as a1,'00:40' as a2,'mouse' as a3,'11' as a4 union all
- select '2022/11/17' as a1,'00:40' as a2,'trumpet' as a3,'33' as a4 union all
- select '2022/11/17' as a1,'00:40' as a2,'screen' as a3,'44' as a4 union all
- select '2022/11/17' as a1,'00:55' as a2,'keyboard' as a3,'55' as a4 union all
- select '2022/11/17' as a1,'00:55' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/17' as a1,'00:55' as a2,'trumpet' as a3,'77' as a4 union all
- select '2022/11/17' as a1,'00:55' as a2,'screen' as a3,'88' as a4 union all
- select '2022/11/18' as a1,'00:03' as a2,'keyboard' as a3,'88' as a4 union all
- select '2022/11/18' as a1,'00:03' as a2,'mouse' as a3,'77' as a4 union all
- select '2022/11/18' as a1,'00:03' as a2,'trumpet' as a3,'66' as a4 union all
- select '2022/11/18' as a1,'00:03' as a2,'screen' as a3,'55' as a4 union all
- select '2022/11/18' as a1,'00:20' as a2,'keyboard' as a3,'99' as a4 union all
- select '2022/11/18' as a1,'00:20' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/18' as a1,'00:20' as a2,'trumpet' as a3,'55' as a4 union all
- select '2022/11/18' as a1,'00:20' as a2,'screen' as a3,'33' as a4 union all
- select '2022/11/18' as a1,'00:40' as a2,'keyboard' as a3,'22' as a4 union all
- select '2022/11/18' as a1,'00:40' as a2,'mouse' as a3,'11' as a4 union all
- select '2022/11/18' as a1,'00:40' as a2,'trumpet' as a3,'33' as a4 union all
- select '2022/11/18' as a1,'00:40' as a2,'screen' as a3,'44' as a4 union all
- select '2022/11/18' as a1,'00:55' as a2,'keyboard' as a3,'55' as a4 union all
- select '2022/11/18' as a1,'00:55' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/18' as a1,'00:55' as a2,'trumpet' as a3,'77' as a4 union all
- select '2022/11/18' as a1,'00:55' as a2,'screen' as a3,'88' as a4 union all
- select '2022/11/19' as a1,'00:03' as a2,'keyboard' as a3,'88' as a4 union all
- select '2022/11/19' as a1,'00:03' as a2,'mouse' as a3,'77' as a4 union all
- select '2022/11/19' as a1,'00:03' as a2,'trumpet' as a3,'66' as a4 union all
- select '2022/11/19' as a1,'00:03' as a2,'screen' as a3,'55' as a4 union all
- select '2022/11/19' as a1,'00:20' as a2,'keyboard' as a3,'99' as a4 union all
- select '2022/11/19' as a1,'00:20' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/19' as a1,'00:20' as a2,'trumpet' as a3,'55' as a4 union all
- select '2022/11/19' as a1,'00:20' as a2,'screen' as a3,'33' as a4 union all
- select '2022/11/19' as a1,'00:40' as a2,'keyboard' as a3,'22' as a4 union all
- select '2022/11/19' as a1,'00:40' as a2,'mouse' as a3,'11' as a4 union all
- select '2022/11/19' as a1,'00:40' as a2,'trumpet' as a3,'33' as a4 union all
- select '2022/11/19' as a1,'00:40' as a2,'screen' as a3,'44' as a4 union all
- select '2022/11/19' as a1,'00:55' as a2,'keyboard' as a3,'55' as a4 union all
- select '2022/11/19' as a1,'00:55' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/19' as a1,'00:55' as a2,'trumpet' as a3,'77' as a4 union all
- select '2022/11/19' as a1,'00:55' as a2,'screen' as a3,'88' as a4 union all
- select '2022/11/20' as a1,'00:03' as a2,'keyboard' as a3,'88' as a4 union all
- select '2022/11/20' as a1,'00:03' as a2,'mouse' as a3,'77' as a4 union all
- select '2022/11/20' as a1,'00:03' as a2,'trumpet' as a3,'66' as a4 union all
- select '2022/11/20' as a1,'00:03' as a2,'screen' as a3,'55' as a4 union all
- select '2022/11/20' as a1,'00:20' as a2,'keyboard' as a3,'99' as a4 union all
- select '2022/11/20' as a1,'00:20' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/20' as a1,'00:20' as a2,'trumpet' as a3,'55' as a4 union all
- select '2022/11/20' as a1,'00:20' as a2,'screen' as a3,'33' as a4 union all
- select '2022/11/20' as a1,'00:40' as a2,'keyboard' as a3,'22' as a4 union all
- select '2022/11/20' as a1,'00:40' as a2,'mouse' as a3,'11' as a4 union all
- select '2022/11/20' as a1,'00:40' as a2,'trumpet' as a3,'33' as a4 union all
- select '2022/11/20' as a1,'00:40' as a2,'screen' as a3,'44' as a4 union all
- select '2022/11/20' as a1,'00:55' as a2,'keyboard' as a3,'55' as a4 union all
- select '2022/11/20' as a1,'00:55' as a2,'mouse' as a3,'66' as a4 union all
- select '2022/11/20' as a1,'00:55' as a2,'trumpet' as a3,'77' as a4 union all
- select '2022/11/20' as a1,'00:55' as a2,'screen' as a3,'88' as a4 )ret
- where ret.a2 = '00:20' order by a1 desc limit 10 ) ret2
- where a3 = 'keyboard'
複製代碼
... |