Results 1 to 3 of 3

Thread: SQL- SUM

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Singapore
    Posts
    43

    Post

    Hi Guys,
    I got this problem with my table as i'm trying to sum up the results of the whole row of records. E.g.

    Total
    ------
    4
    5
    5
    5

    so the total should be 19. But when i used the following code:

    Select SUM(Total) GrandTotal From Table

    When i used a MshFlexGrid to view the result
    I got this error:

    Syntax Error missing operator in query expression 'SUM(Total) GrandTotal From Table
    '
    Please Help. And can anyone intro me to a site where i can find more help for SQL ?

    Thks.

  2. #2
    Member
    Join Date
    Mar 1999
    Location
    España
    Posts
    45

    Post

    Hello,

    I think it's very easy, yor SQL string is wrong, you wrote this :
    'SELECT SUM(Total) GrandTotal From Table'

    But if you want to create a calculated field, you must use this sintaxis:
    'SELECT SUM(Total) AS GrandTotal From Table'

    This 'AS' indicates that the calculated field 'SUM(Total)' is going to be called 'GrandTotal' in the code.

    I want to be helpfully for you.

    Bye.


  3. #3

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Singapore
    Posts
    43

    Post

    First of all thanks for your help

    But what i meant to do is to add a new column after the sum up as Grandtotal and not to see the result only as Grandtotal in the table itself.
    E.g.

    Total GrandTotal
    ----- ----------
    4 19
    5
    5
    5

    ??? Any solution??? Thks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width