Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>>> Do you always have the fifteen minute intervals?
>
>No. The records are built during a "midnight run" process and the time interval is based off how the resource is defined. It is in at least 5 minute intervals. The min time a resource is allowed to be scheduled is 5 minutes and the interval is incremented in 5 minute increments.
>
>Thanks for your thoughts
>
>Kirk
As it turns out, the intervals between records don't matter.
I assume that restime is a datetime field so I can add and subtract one hour this way:
SELECT OneHour.pk FROM onehour INNER JOIN onehour AS one1 ON onehour.resgrp = one1.resgrp AND onehour.restime <= one1.restime AND onehour.restime > one1.restime - 3600 WHERE onehour.Resused = .F. AND one1.Resused = .T. INTO CURSOR oneout
I thought I could combine the following two queries into one, but I had to use two. The WHERE ISNULL(something) method is similar to a NOT IN (subquery) but should go faster.
SELECT OneHour.pk,onehour.resgrp,onehour.restime,oneout.pk AS otherkey FROM onehour LEFT OUTER JOIN oneout ON onehour.pk = oneout.pk WHERE onehour.Resused = .F. INTO CURSOR oneonly
SELECT * FROM oneonly INTO CURSOR onlyone WHERE ISNULL(otherkey)
Final result:
SELECT onehour.pk,onehour.reskey,onehour.resgrp,onehour.restime FROM onehour INNER JOIN onlyone ON onehour.resgrp = onlyone.resgrp AND onehour.restime >= onlyone.restime AND onehour.restime < onlyone.restime + 3600 INTO CURSOR oneresult ORDER BY 2,3,4
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement