Results 1 to 4 of 4

Thread: [Resolved] "Quantity" Count Help in SQL Expression

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sinagpore
    Posts
    42

    Resolved [Resolved] "Quantity" Count Help in SQL Expression

    I'm developing an inventory application. There is a column "Product Name" and a column "Quantity". I wish to group the same product name together to produce a quantity.

    What I mean is:

    Product_Name

    Coke
    Coke
    Coke

    Total of coke is: 3

    So I have these expression currently : SELECT Product_Name, SUM ('Inventory'.i duno how 2 continue) FROM 'Inventory' GROUP BY Product_Name

    What i wish to do is the statement will group similar product_name's names together and count how many records are repetitve by the similar names.

    Thanks in advance.
    Last edited by Warren Ang; Jan 9th, 2005 at 09:38 PM. Reason: Resolved

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: "Quantity" Count Help in SQL Expression

    I think this should do the trick for you.
    Code:
    "SELECT SUM(YourTable!Quantity) FROM YourTableName WHERE [Product Name] = 'coke'"

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: "Quantity" Count Help in SQL Expression

    Lintz's method is fine if you are looking for a specific product, but not for multiple products. If that is what you want then one of these will probably do what you want:

    If you want a total of the "Quantity" field per unique value in "Product_Name" then use this:
    Code:
    SELECT Product_Name, SUM (Quantity) 
    FROM 'Inventory' 
    GROUP BY Product_Name
    If you just want to return the number of rows containing each Product_Name then use this:
    Code:
    SELECT Product_Name, count(Product_Name) 
    FROM 'Inventory' 
    GROUP BY Product_Name

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sinagpore
    Posts
    42

    Re: "Quantity" Count Help in SQL Expression

    Ok thanks. It is resolved. I used the 2nd method and it works.

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