Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    7

    Unanswered: Perform a sort for multiple tables

    I have a table called 'Tasks' and another called 'Queues'. Each task is added to the Task table and has a reference to a row in Queues. There is also a field called TimeModified for each task, which represents the time a task is created or modified. What I want is some way of selecting the queue with the earliest TimeModified value. But the Queues table will not have this field, but it should somehow find it from the Tasks within the queue.

    For example:

    Queue table
    Code:
    QueueId | Active
    1       | Yes
    2       | Yes
    Task table
    Code:
    Task Id | TaskModified      | QueueId | TaskComplete
    100     | 10/06/2012 10:00  | 1       | No
    101     | 10/06/2012 10:01  | 1       | No 
    102     | 10/06/2012 10:02  | 2       | No
    Imagine the tasks above are submitted in sequence. At 10:03 processing is completed on the earliest task which is 100. The table then looks like this:

    Code:
    Task Id | TaskModified      | QueueId | TaskComplete
    100     | 10/06/2012 10:03  | 1       | Yes
    101     | 10/06/2012 10:01  | 1       | No 
    102     | 10/06/2012 10:02  | 2       | No
    So then processing begins on the next task. But what is the next task? It is not 101 even though it has the earliest timestamp. It is 102 because it is Queue 2 that has the earliest timestamp of 10:01 as Queue 1 has the timestamp of 10:03.

    To give you an idea of what could be done, when the above state is reached a query could look like this:

    Code:
    QueueId | Active | QueueModified 
    1       | Yes    | 10/06/2012 10:03
    2       | Yes    | 10/06/2012 10:02
    Here you see that it is Queue 2 that has the earliest modified timestamp. From this query another query could be done to find the task within queue 2 that has the earliest modified timestamp (which is 102) and work on that. Ideally my queue should show the TaskId as well but it's not a must.

    Any ideas on how I could achieve this?
    Last edited by Elph; 06-17-12 at 16:37.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    don't understand the description, sorry.. therefore cant help
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •