Results 1 to 6 of 6

Thread: sql query

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Unanswered: sql query

    i have two tables abc which has a column total and xyz which has a field marks and i want to sum up the values of column marks of xyz and
    i want to add the result of sum of marks with a column total of abc
    please reply the query soon

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    we will need to see the DDL or at least some more details
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT abc.somekey
         , abc.total + SUM(xyz.marks) AS result
      FROM abc
    INNER
      JOIN xyz
        ON xyz.somekey = abc.somekey
    GROUP
        BY abc.somekey
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I...don't think that will work

    , SUM(abc.total) + SUM(xyz.marks) AS result

    ???
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Apr 2012
    Posts
    2

    doesn't work

    the code u provided doesnt work properly, there's some error on the code

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bunzitop View Post
    the code u provided doesnt work properly, there's some error on the code
    two people provided code to you, which one are you referring to?

    also, what was the exact error message?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

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