Home > database >  Essentially a script: access to reach a certain condition the earliest time?
Essentially a script: access to reach a certain condition the earliest time?

Time:10-09

ReadDateTime score
The 2019-04-01 10:58:23. 997 0.1
The 2019-04-01 11:01:39. 500 0.1
The 2019-04-01 11:05:16. 737 0.1
The 2019-04-01 11:21:11. 570 0.1
The 2019-04-01 11:35:22. 210 0.5
The 2019-04-01 11:35:56. 117 0.1
The 2019-04-01 11:37:11. 197 0.1
The 2019-04-01 13:27:18. 313 0.1
The 2019-04-01 13:27:27. 140 0.1
The 2019-04-01 13:27:28. 517 0.1
The 2019-04-01 13:28:00. 890 0.1
The 2019-04-01 13:31:28. 837 0.1
The 2019-04-02 08:11:14. 697 0.1
The 2019-04-02 08:13:23. 173 0.5
The 2019-04-02 08:18:33. 657 0.1
The 2019-04-02 08:21:10. 977 0.5
The 2019-04-02 08:23:40. 130 0.5
The 2019-04-04 21:04:13. 487 0.1
The 2019-04-04 21:04:47. 660 0.1
The 2019-04-04 21:06:57. 103 0.5
The 2019-04-04 21:10:12. 830 0.5
The 2019-04-04 21:11:15. 630 0.1
The 2019-04-04 21:16:10. 733 0.5
The 2019-04-04 21:17:55. 593 0.1
The 2019-04-04 21:19:58. 833 0.5
The 2019-04-04 21:42:13. 257 0.1
The 2019-04-04 21:45:26. 907 0.5
The 2019-04-04 21:55:17. 640 0.1
The 2019-04-04 21:58:15. 667 0.5
The 2019-04-04 21:59:04. 057 0.1
The 2019-04-04 22:00:09. 890 0.1
The 2019-04-04 22:00:49. 643 0.1
The 2019-04-04 22:01:12. 660 0.5
The 2019-04-04 22:02:37. 667 0.1
The 2019-04-15 15:59:14. 847 0.1
The 2019-04-15 16:16:35. 800 0.5
The 2019-04-15 16:22:00. 097 0.5
The 2019-04-15 16:38:39. 117 0.5
The 2019-04-15 16:39:25. 040 0.1
The 2019-04-15 16:42:10. 913 0.1
The 2019-04-15 16:43:43. 663 0.1
The 2019-04-15 16:50:19. 620 0.5
The 2019-04-15 16:55:33. 417 0.1
The 2019-04-15 17:08:05. 200 0.5
The 2019-04-15 19:46:32. 627 0.1
The 2019-04-15 19:46:44. 580 0.1
The 2019-04-15 19:46:47. 660 0.1
The 2019-04-15 20:07:49. 803 0.5
The 2019-04-15 20:27:57. 180 0.1
2019-04-15 20:34:09. 993 0.5
The 2019-04-15 20:34:52. 947 0.1
The 2019-04-15 20:57:21. 560 0.1
The 2019-04-15 20:57:24. 607 0.1
The 2019-04-15 21:01:39. 230 0.5
The 2019-04-15 21:02:50. 573 0.1
The 2019-04-15 21:02:52. 967 0.1
The 2019-04-15 21:04:31. 513 0.5
The 2019-04-15 21:04:53. 230 0.1
The 2019-04-15 21:10:01. 137 0.5
The 2019-04-15 21:10:03. 123 0.1
The 2019-04-15 21:10:10. 217 0.1
The 2019-04-15 21:15:01. 390 0.5
The 2019-04-15 21:35:40. 907 0.1
The 2019-04-15 21:41:07. 080 0.5
The 2019-04-15 21:45:16. 987 0.1
The 2019-04-15 21:46:04. 987 0.1
The 2019-04-15 21:46:19. 300 0.1
The 2019-04-15 21:46:21. 893 0.1
The 2019-04-15 21:54:22. 830 0.5
The 2019-04-15 21:55:04. 080 0.1
The 2019-04-15 21:55:34. 207 0.5


As shown in the above, read detail record: time and get scores;
Get a score reach 5 points at the earliest time?
In addition to the cursor, have better SQL?

CodePudding user response:

Row_number the function,

CodePudding user response:

reference 1st floor selling fruit net reply:
row_number the function,


Is the total score, is ascending order according to time, the sum (score) & gt; One of the earliest time=5

CodePudding user response:

Total score, the sum () over (order by)
  • Related