Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Cool Unanswered: Oracle Query writing for Totoal Calcultions ?

    Hi All,

    Can any one help in writing query for calculation of total for the following table :

    sno sname maths physics chemistry total
    10101 raju 68 69 70
    10102 ravi 56 78 80
    10103 ramu 66 58 75
    10104 venkat 86 65 74
    10105 laxman 73 62 60
    10106 raghu 85 75 80
    10107 basha 69 58 69
    10108 shiva 85 78 75
    10109 suresh 65 67 75
    10110 sreekanth 68 65 75

    i want to add total like (maths+physics+chemistry) for all of them at a time and that too with a single query.

    please some one help me

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Code:
    SELECT sum(maths+physics+chemistry)
    FROM the_unknown_table

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    shammat, really, what good is knowing that the entire class got a total mark of 733 in chemistry???

    i think this is what he was after...
    Code:
    SELECT sno
         , sname
         , maths
         , physics
         , chemistry 
         , COALESCE(maths,0)+COALESCE(physics,0)+COALESCE(chemistry,0) 
                AS total
      FROM daTable
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by r937
    shammat, really, what good is knowing that the entire class got a total mark of 733 in chemistry???
    I know

    I just wanted to show that insufficient input results in an inappropriate solution...

    balap_chander did not tell us what the desired output should be, and taking the amount of information provided, your guess regarding what the output should be is just as good as my guess

Posting Permissions

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