Results 1 to 3 of 3

Thread: Query db

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Query db

    How i select the sum of each row by quantity and group by cod?

    id cod quantity
    1 pinco 4
    2 panco 3
    3 panco 9

    i want from that query:

    pinco sum is 4
    panco sum is 13

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,440

    Re: Query db

    Quote Originally Posted by hamon View Post
    How i select the sum of each row by quantity and group by cod?

    id cod quantity
    1 pinco 4
    2 panco 3
    3 panco 9

    i want from that query:

    pinco sum is 4
    panco sum is 13
    Uhhh.... start learning SQL?

    SQL Code:
    1. SELECT
    2. cod,
    3. SUM(quantity) As qty
    4. FROM
    5. MyTable
    6. GROUP BY
    7. cod


    EDIT: Just saw it: Yeah, 9 + 3 is 13 .......
    Add basic math to learning SQL.....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Re: Query db

    Yep, i start. thank you.

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