Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Location
    South Africa
    Posts
    33

    Unanswered: doing a "join" to the same table ??

    I do not know if this is possible :

    I want to do calculations of time. I have a table that has the following columns:

    name
    datetime
    sequence
    id

    I want to calculate the time between two seperate sequence's?? but where the id's are the same and the names are the same?? From the same table ??

    Is this possible ???

    MANY THANKS

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    of course it's possible

    select x.name, x.sequence, y.sequence
    , x.datetime - y.datetime
    from yourtable as x
    inner join yourtable as y
    on x.name = y.name and x.id = y.id

    this will give all possible pairings, and in particular, it will give the same pair twice, and you will notice this when you see the positive and negative results for the datetime difference

    by the way, be careful not to declare your column names using reserved words -- you are only asking for syntax errors

    rudy
    http://rudy.ca/

  3. #3
    Join Date
    Nov 2001
    Location
    South Africa
    Posts
    33
    Many thanks :)

    by the way, be careful not to declare your column names using reserved words -- you are only asking for syntax errors

    will do ...

    Thanks again ....

Posting Permissions

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