MySQL statement help

Source: Internet
Author: User
Now on such a table, to find out the project code the same column of total revenue, SQL statement how to write, Help the hero help, come out the result is so show, hope the master to help see, in this thank


Reply to discussion (solution)

Select Project code, project name, SUM (revenue) from the table group by project code

First of all, the SQL summation must definitely require the aggregate function of MySQL sum (field name)
You need a group. Group By field names, of course
It's already written upstairs.

Upstairs, I won't repeat it.

Select AVG (' Project code '), ' project name ', SUM (' revenue ') from the table group by ' project name '

1L Group by this kind of writing seems to hang

Select Project code, project name, SUM (revenue) as revenue from table name group by project code;

Project code, project name, SUM (revenue): The column to display,
As income: give the new total revenue this column alias (call the total revenue better?),
Group BY Project code: indicates that the above query is preceded by the "Project Code" group "and then added to the calculation."

It's been solved, thank you, it's hard.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.