Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Time Variance Query works - Sorry it needs a tweak

Time Variance Query works - Sorry it needs a tweak

Scheduled Pinned Locked Moved Database
databasequestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_berman
    wrote on last edited by
    #1

    So this query now works really well SELECT DISTINCT b.event_id AS a, b.user_ID AS a, b.date AS a, b.Time AS a FROM quadrantids2017 AS a JOIN quadrantids2017 AS b WHERE a.`date` = b.`date` AND a.user_ID != b.user_ID AND time_to_sec(a.`Time`) - time_to_sec(b.`Time`) BETWEEN -30 AND 30 ORDER BY a.date ASC, a.Time ASC, a.user_ID ASC I have two issues 1 - Its slow, there are 3144 records and its taking 37 seconds to get the result which is 1519 records so I added an index to event,_id, user_id, date and time and its reduced to 24 secs 2 - It returns the results like this 33501 1 2017-01-01 01:14:59 47829 3 2017-01-01 01:24:49 33503 1 2017-01-01 01:24:48 37787 2 2017-01-01 02:21:13 33504 1 2017-01-01 02:20:43 47837 3 2017-01-01 03:06:19 33505 1 2017-01-01 03:06:17 47838 3 2017-01-01 03:07:30 33506 1 2017-01-01 03:07:28 33507 1 2017-01-01 03:07:42 47840 3 2017-01-01 04:35:12 33510 1 2017-01-01 04:35:11 Im wondering how I might show the related results ie 47829 3 2017-01-01 01:24:49 33503 1 2017-01-01 01:24:48 37787 2 2017-01-01 02:21:13 33504 1 2017-01-01 02:20:43 47837 3 2017-01-01 03:06:19 33505 1 2017-01-01 03:06:17 47838 3 2017-01-01 03:07:30 33506 1 2017-01-01 03:07:28 33507 1 2017-01-01 03:07:42 47840 3 2017-01-01 04:35:12 33510 1 2017-01-01 04:35:11 Is there any way I can add a group number to each record or something like that ? John B

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups