找回密碼 或 安全提問
 註冊
|註冊|登錄

伊莉討論區

搜索
感激所有對伊莉作出奉獻的人發表文章前請先閱讀相關版規認識好友、聊天,分享生活趣事
officefc2julia新竹惡靈古堡按摩安卓
lwt amerebwh 054舞動青春高中平瀬マリミカのし<font st

休閒聊天興趣交流學術文化旅遊交流飲食交流家庭事務PC GAMETV GAME
熱門線上其他線上感情感性寵物交流家族門派動漫交流貼圖分享BL/GL
音樂世界影視娛樂女性頻道潮流資訊BT下載區GB下載區下載分享短片
電腦資訊數碼產品手機交流交易廣場網站事務長篇小說體育運動時事經濟
上班一族博彩娛樂

✡ 凡人修仙傳・124・

[繁]在地下城尋求邂逅

[繁]七龍珠大魔02-

(10月新番)[繁]在地下

(10月新番)[簡]重啟人

(10月新番)[繁]平凡職
電腦新資訊電腦軟體討論電腦軟體資訊分享電腦硬體討論電腦硬體資訊分享電腦萌化版電腦系統 OS 討論電腦程式設計
電腦設計技術交流圖像設計及交流各類下載工具教學寬頻上網討論
查看: 53597|回復: 1
打印上一主題下一主題

[求助]mysql過濾條件加總問題[複製鏈接]

Rank: 2Rank: 2

帖子
168
積分
370 點
潛水值
9638 米
跳轉到指定樓層
樓主
發表於 2022-11-18 06:33 PM|只看該作者|倒序瀏覽
成為伊莉的版主,你將獲得更高級和無限的權限。把你感興趣的版面一步步地發展和豐盛,那種滿足感等著你來嚐嚐喔。
想請教各位大大,我要如何從以下表下sql抓取最後10筆00:20的keyboard的數量加總?

日期

時間

欄位

數量

2022/11/17

00:03

keyboard

88

2022/11/17

00:03

mouse

77

2022/11/17

00:03

trumpet

66

2022/11/17

00:03

screen

55

2022/11/17

00:20

keyboard

99

2022/11/17

00:20

mouse

66

2022/11/17

00:20

trumpet

55

2022/11/17

00:20

screen

33

2022/11/17

00:40

keyboard

22

2022/11/17

00:40

mouse

11

2022/11/17

00:40

trumpet

33

2022/11/17

00:40

screen

44

2022/11/17

00:55

keyboard

55

2022/11/17

00:55

mouse

66

2022/11/17

00:55

trumpet

77

2022/11/17

00:55

screen

88

2022/11/18

00:03

keyboard

88

2022/11/18

00:03

mouse

77

2022/11/18

00:03

trumpet

66

2022/11/18

00:03

screen

55

2022/11/18

00:20

keyboard

99

2022/11/18

00:20

mouse

66

2022/11/18

00:20

trumpet

55

2022/11/18

00:20

screen

33

2022/11/18

00:40

keyboard

22

2022/11/18

00:40

mouse

11

2022/11/18

00:40

trumpet

33

2022/11/18

00:40

screen

44

2022/11/18

00:55

keyboard

55

2022/11/18

00:55

mouse

66

2022/11/18

00:55

trumpet

77

2022/11/18

00:55

screen

88

2022/11/19

00:03

keyboard

88

2022/11/19

00:03

mouse

77

2022/11/19

00:03

trumpet

66

2022/11/19

00:03

screen

55

2022/11/19

00:20

keyboard

99

2022/11/19

00:20

mouse

66

2022/11/19

00:20

trumpet

55

2022/11/19

00:20

screen

33

2022/11/19

00:40

keyboard

22

2022/11/19

00:40

mouse

11

2022/11/19

00:40

trumpet

33

2022/11/19

00:40

screen

44

2022/11/19

00:55

keyboard

55

2022/11/19

00:55

mouse

66

2022/11/19

00:55

trumpet

77

2022/11/19

00:55

screen

88

2022/11/20

00:03

keyboard

88

2022/11/20

00:03

mouse

77

2022/11/20

00:03

trumpet

66

2022/11/20

00:03

screen

55

2022/11/20

00:20

keyboard

99

2022/11/20

00:20

mouse

66

2022/11/20

00:20

trumpet

55

2022/11/20

00:20

screen

33

2022/11/20

00:40

keyboard

22

2022/11/20

00:40

mouse

11

2022/11/20

00:40

trumpet

33

2022/11/20

00:40

screen

44

2022/11/20

00:55

keyboard

55

2022/11/20

00:55

mouse

66

2022/11/20

00:55

trumpet

77

2022/11/20

00:55

screen

88

...
瀏覽完整內容,請先 註冊登入會員
分享分享0收藏收藏0支持支持0

使用道具檢舉

Rank: 1

帖子
70
積分
164 點
潛水值
13117 米
頭香
發表於 2023-2-8 11:04 AM|只看該作者
本帖最後由 yku 於 2023-2-8 11:05 AM 編輯
  1. select sum(ret2.a4) as sum_tot
  2. from(
  3. select ret.*
  4. from (
  5. select '2022/11/17' as a1,'00:03' as a2,'keyboard' as  a3,'88' as a4 union all
  6. select '2022/11/17' as a1,'00:03' as a2,'mouse' as  a3,'77' as a4 union all
  7. select '2022/11/17' as a1,'00:03' as a2,'trumpet' as  a3,'66' as a4 union all
  8. select '2022/11/17' as a1,'00:03' as a2,'screen' as  a3,'55' as a4 union all
  9. select '2022/11/17' as a1,'00:20' as a2,'keyboard' as  a3,'99' as a4 union all
  10. select '2022/11/17' as a1,'00:20' as a2,'mouse' as  a3,'66' as a4 union all
  11. select '2022/11/17' as a1,'00:20' as a2,'trumpet' as  a3,'55' as a4 union all
  12. select '2022/11/17' as a1,'00:20' as a2,'screen' as  a3,'33' as a4 union all
  13. select '2022/11/17' as a1,'00:40' as a2,'keyboard' as  a3,'22' as a4 union all
  14. select '2022/11/17' as a1,'00:40' as a2,'mouse' as  a3,'11' as a4 union all
  15. select '2022/11/17' as a1,'00:40' as a2,'trumpet' as  a3,'33' as a4 union all
  16. select '2022/11/17' as a1,'00:40' as a2,'screen' as  a3,'44' as a4 union all
  17. select '2022/11/17' as a1,'00:55' as a2,'keyboard' as  a3,'55' as a4 union all
  18. select '2022/11/17' as a1,'00:55' as a2,'mouse' as  a3,'66' as a4 union all
  19. select '2022/11/17' as a1,'00:55' as a2,'trumpet' as  a3,'77' as a4 union all
  20. select '2022/11/17' as a1,'00:55' as a2,'screen' as  a3,'88' as a4 union all
  21. select '2022/11/18' as a1,'00:03' as a2,'keyboard' as  a3,'88' as a4 union all
  22. select '2022/11/18' as a1,'00:03' as a2,'mouse' as  a3,'77' as a4 union all
  23. select '2022/11/18' as a1,'00:03' as a2,'trumpet' as  a3,'66' as a4 union all
  24. select '2022/11/18' as a1,'00:03' as a2,'screen' as  a3,'55' as a4 union all
  25. select '2022/11/18' as a1,'00:20' as a2,'keyboard' as  a3,'99' as a4 union all
  26. select '2022/11/18' as a1,'00:20' as a2,'mouse' as  a3,'66' as a4 union all
  27. select '2022/11/18' as a1,'00:20' as a2,'trumpet' as  a3,'55' as a4 union all
  28. select '2022/11/18' as a1,'00:20' as a2,'screen' as  a3,'33' as a4 union all
  29. select '2022/11/18' as a1,'00:40' as a2,'keyboard' as  a3,'22' as a4 union all
  30. select '2022/11/18' as a1,'00:40' as a2,'mouse' as  a3,'11' as a4 union all
  31. select '2022/11/18' as a1,'00:40' as a2,'trumpet' as  a3,'33' as a4 union all
  32. select '2022/11/18' as a1,'00:40' as a2,'screen' as  a3,'44' as a4 union all
  33. select '2022/11/18' as a1,'00:55' as a2,'keyboard' as  a3,'55' as a4 union all
  34. select '2022/11/18' as a1,'00:55' as a2,'mouse' as  a3,'66' as a4 union all
  35. select '2022/11/18' as a1,'00:55' as a2,'trumpet' as  a3,'77' as a4 union all
  36. select '2022/11/18' as a1,'00:55' as a2,'screen' as  a3,'88' as a4 union all
  37. select '2022/11/19' as a1,'00:03' as a2,'keyboard' as  a3,'88' as a4 union all
  38. select '2022/11/19' as a1,'00:03' as a2,'mouse' as  a3,'77' as a4 union all
  39. select '2022/11/19' as a1,'00:03' as a2,'trumpet' as  a3,'66' as a4 union all
  40. select '2022/11/19' as a1,'00:03' as a2,'screen' as  a3,'55' as a4 union all
  41. select '2022/11/19' as a1,'00:20' as a2,'keyboard' as  a3,'99' as a4 union all
  42. select '2022/11/19' as a1,'00:20' as a2,'mouse' as  a3,'66' as a4 union all
  43. select '2022/11/19' as a1,'00:20' as a2,'trumpet' as  a3,'55' as a4 union all
  44. select '2022/11/19' as a1,'00:20' as a2,'screen' as  a3,'33' as a4 union all
  45. select '2022/11/19' as a1,'00:40' as a2,'keyboard' as  a3,'22' as a4 union all
  46. select '2022/11/19' as a1,'00:40' as a2,'mouse' as  a3,'11' as a4 union all
  47. select '2022/11/19' as a1,'00:40' as a2,'trumpet' as  a3,'33' as a4 union all
  48. select '2022/11/19' as a1,'00:40' as a2,'screen' as  a3,'44' as a4 union all
  49. select '2022/11/19' as a1,'00:55' as a2,'keyboard' as  a3,'55' as a4 union all
  50. select '2022/11/19' as a1,'00:55' as a2,'mouse' as  a3,'66' as a4 union all
  51. select '2022/11/19' as a1,'00:55' as a2,'trumpet' as  a3,'77' as a4 union all
  52. select '2022/11/19' as a1,'00:55' as a2,'screen' as  a3,'88' as a4 union all
  53. select '2022/11/20' as a1,'00:03' as a2,'keyboard' as  a3,'88' as a4 union all
  54. select '2022/11/20' as a1,'00:03' as a2,'mouse' as  a3,'77' as a4 union all
  55. select '2022/11/20' as a1,'00:03' as a2,'trumpet' as  a3,'66' as a4 union all
  56. select '2022/11/20' as a1,'00:03' as a2,'screen' as  a3,'55' as a4 union all
  57. select '2022/11/20' as a1,'00:20' as a2,'keyboard' as  a3,'99' as a4 union all
  58. select '2022/11/20' as a1,'00:20' as a2,'mouse' as  a3,'66' as a4 union all
  59. select '2022/11/20' as a1,'00:20' as a2,'trumpet' as  a3,'55' as a4 union all
  60. select '2022/11/20' as a1,'00:20' as a2,'screen' as  a3,'33' as a4 union all
  61. select '2022/11/20' as a1,'00:40' as a2,'keyboard' as  a3,'22' as a4 union all
  62. select '2022/11/20' as a1,'00:40' as a2,'mouse' as  a3,'11' as a4 union all
  63. select '2022/11/20' as a1,'00:40' as a2,'trumpet' as  a3,'33' as a4 union all
  64. select '2022/11/20' as a1,'00:40' as a2,'screen' as  a3,'44' as a4 union all
  65. select '2022/11/20' as a1,'00:55' as a2,'keyboard' as  a3,'55' as a4 union all
  66. select '2022/11/20' as a1,'00:55' as a2,'mouse' as  a3,'66' as a4 union all
  67. select '2022/11/20' as a1,'00:55' as a2,'trumpet' as  a3,'77' as a4 union all
  68. select '2022/11/20' as a1,'00:55' as a2,'screen' as  a3,'88' as a4 )ret
  69. where ret.a2 = '00:20' order by a1 desc limit 10  ) ret2
  70. where a3 = 'keyboard'
複製代碼

...
瀏覽完整內容,請先 註冊登入會員
成為伊莉的版主,你將獲得更高級和無限的權限。把你感興趣的版面一步步地發展和豐盛,那種滿足感等著你來嚐嚐喔。

使用道具檢舉

您需要登錄後才可以回帖 登錄 | 註冊

Powered by Discuz!

© Comsenz Inc.

重要聲明:本討論區是以即時上載留言的方式運作,對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。 由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿上傳和撰寫 侵犯版權(未經授權)、粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。
回頂部