Sum function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parallax
    New Member
    • Apr 2007
    • 10

    #1

    Sum function

    Hi Guys,

    this is my table

    mysql> select * from data;
    +------------+-----------------------------+---------+----------+
    | date | name | missing | advanced |
    +------------+-----------------------------+---------+----------+
    | 2007-04-05 | Abraao | 2 | |
    | 2007-04-06 | Adeilson Sousa | | 50,00 |
    | 2007-03-14 | Abraao | | 35,00 |
    | 2007-04-07 | Roberto Saturnino Alves| 2 | 20,00 |
    | 2007-04-06 | Roberto Saturnino Alves| | 35,00 |
    | 2007-04-07 | Abraao | | 40,00 |
    | 2007-04-10 | Raphael Miguel Targin | 2 | 35,00 |
    | 2007-04-10 | Rosemere Santana Neves | | 45,00 |
    | 2007-04-10 | Carlos Frederico De Andrade | 1 | 35,00 |
    | 2007-04-10 | Bruno Miguel Targino | 2 | 25,00 |
    | 2007-04-10 | Vania Soraia Vaz Naia | 5 | 15,00 |
    +------------+-----------------------------+---------+----------+
    11 rows in set (0.00 sec)

    i need to sum the values of advanced by the name of the people...
    could someone help me please?
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Code:
    SELECT SUM(advanced) AS total_advance FROM data GROUP BY name;

    Comment

    • parallax
      New Member
      • Apr 2007
      • 10

      #3
      Thanks a lot...

      Comment

      • parallax
        New Member
        • Apr 2007
        • 10

        #4
        Code:
        "SELECT name, SUM(advanced) AS total_advance FROM data GROUP BY name where MONTH(date) = 04";
        why does it not work?????

        Comment

        • miller
          Recognized Expert Top Contributor
          • Oct 2006
          • 1086

          #5
          Because some of your values are not actually numbers as they contain commas:

          Code:
          | 2007-04-06 | Roberto Saturnino Alves|         | [b]35,00[/b]    |
          - Miller

          Comment

          Working...