sum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • voroojak
    New Member
    • Feb 2007
    • 92

    sum

    i have 3 columns that i want to add them horizontally and vertically. if i just wantt o add them horizontally i can di it by adding the columns but i dont know how cani add them verticall that i can see the result all together.
    something like this

    A B C
    name 1 100 5 23
    name 2 54 23 14
    name 3 26 87 1

    i want to have the sum of each column and each row. i want to have out put something like this

    A B C total
    name 1 100 5 23 128
    name 2 54 23 14 91
    name 3 26 87 1 114
    Total 180 115 38 233


    thanks alot
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Like this
    You will need to adjust the table and field names to suit
    [code=sql]
    SELECT ID,A,B,C,A+B+C as T
    From YourTable
    union all
    SELECT "Total" ,sum(A),sum(B), sum(C),sum(A+B+ C)
    From YourTable
    [/code]

    I haven't tested it so you may need to do a bit of tweeking
    but I think it will work as is.

    Comment

    • voroojak
      New Member
      • Feb 2007
      • 92

      #3
      Thanks
      it worked. you really helped me alot.
      thank youuuuuuuuuuuuu uuuuuuuuuu

      Comment

      • Yogesh Sharma
        New Member
        • Mar 2008
        • 40

        #4
        hi, I want to ask delerna where we write this Query,Select ------??
        Cz when i click Query Tab under Objects, It allows us to Create Query in Design View,Or by using Wizard.
        None of the methods allowe us to write the Query.
        Plz tell me???/

        Comment

        • Delerna
          Recognized Expert Top Contributor
          • Jan 2008
          • 1134

          #5
          Sure
          Click New Query
          Choose Design View
          Close the Show Table Window
          In the View menu click SQL View
          voila... now you can write an SQL query


          Obiously you can do this also with existing queries that were created with the wizard
          Open the query in design mode
          In the View menu click SQL View
          And there is the query

          This is a good way to learn how to write queries with SQL
          Just create it with the wizard and then take a look at how the wizard wrote the query

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Originally posted by Yogesh Sharma
            hi, I want to ask delerna where we write this Query,Select ------??
            Cz when i click Query Tab under Objects, It allows us to Create Query in Design View,Or by using Wizard.
            None of the methods allowe us to write the Query.
            Plz tell me???/
            Please read the thread here
            FAQ - How to Ask a Question
            Your question uses language that makes it more difficult for our Experts to help you and wastes their time.
            Please use properly written English in future when posting to the technical forums.

            ADMIN.

            PS. Please avoid hijacking another thread too in future.

            Comment

            • Yogesh Sharma
              New Member
              • Mar 2008
              • 40

              #7
              Sir I m not Hijacking any other thread...I didn't understand in what way u say that I m hijacking another thead. I have the same problem related to this thread only,dats Y i post the question in this thread.

              Comment

              • Yogesh Sharma
                New Member
                • Mar 2008
                • 40

                #8
                Ok If u have told me,I m posting the question in New Thread.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  Originally posted by Yogesh Sharma
                  Sir I m not Hijacking any other thread...I didn't understand in what way u say that I m hijacking another thead. I have the same problem related to this thread only,dats Y i post the question in this thread.
                  Yogesh, though you may be working on a similar query, your actual question was on the mechanics of getting SQL from an Access QueryDef. It is therefore a thread hijack.

                  You are clearly also continuing to use text-speak abbreviations in posts in technical threads which you've been asked not to do.

                  I really suggest in future that you check your position more carefully before considering arguing. It doesn't reflect on my intelligence.

                  Comment

                  Working...