Results 1 to 2 of 2

Thread: SQL SUM() query

  1. #1
    Join Date
    Feb 2017
    Posts
    1

    Unanswered: SQL SUM() query

    select SUM(physics, maths, science) from Marks where Name='Chinna'


    This is query I executed, as per the rule we need to give one argument for sum() but incase, as mentioned in the above example I need sum up the marks of chinna alone. Then how to execute that query. Kindly find my db and guide me on this query.

    Roll MathsPhysicsScience Name class
    1000 70 78 67 Anitha12
    1001 73 74 80 Banu 12
    1002 81 73 75 Chinna 12
    1003 82 77 82 Gomathi 12
    1004 76 80 66 Jayesh 12
    1005 79 88 70 Kavi 12
    1006 70 80 84 Nandhini 12
    1007 90 83 82 Madhu 12
    1008 91 83 78 Preethi 12

  2. #2
    Join Date
    Oct 2014
    Posts
    278
    Provided Answers: 6
    SELECT

    NAME
    , ISNULL(PHYSICS,0) + ISNULL(MATHS,0) + ISNULL(SCIENCE, 0) AS TOTAL_GRADE

    FROM MARKS

    WHERE NAME = 'CHINNA'

    GROUP BY
    NAME

    Not a 100% of your requirements, this might be worth a try.
    Last edited by VLOOKUP; 02-13-17 at 17:17.

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
  •