#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Calculate on itself


    hi,
    only one table A(autoid, number)
    how SELECT statment result: B(autoid, number, numberB)
    numberB is sum of all the number have autoid > its autoid.
    Thanks
  2. #2
  3. Humble Learner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    280
    Rep Power
    120
    If you have only one table A, then what is B ?
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    857
    Rep Power
    388

    Cool


    Originally Posted by swordsaint
    hi,
    only one table A(autoid, number)
    how SELECT statment result: B(autoid, number, numberB)
    numberB is sum of all the number have autoid > its autoid.
    Thanks
    If you review your SQL 101 course, you will be able to easily answer this homework assignment.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0
    from my head , something like this.....

    Code:
    SELECT
         A.AUTOID,
         A.NUMBER,
         (SELECT
                SUM(B.NUMBER)
           FROM
                TABLEA B
           WHERE
                B.AUTOID>A.AUTOID) TOTAL
    FROM
        TABLEA A
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    857
    Rep Power
    388

    Thumbs down


    Unfortunately you were given the answer and did not learn anything.

    Some people do not understand the knowledge of the ages:

    "Give a man a fish and he will eat one day, Teach a man to fish and he will have food every day"

    Comments on this post

    • clivew agrees

IMN logo majestic logo threadwatch logo seochat tools logo