+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    107

    Grouping field with same item

    Hi,

    I trying to Group field1 with same item. But i cant get "T" group as 1 item.
    Return me 2 "T"s

    Code:
    SELECT Table1.Field1, Table1.Field2
    FROM Table1
    GROUP BY Table1.Field1, Table1.Field2;

    Query Result:
    HTML Code:
    Field1	Field2
    K	2
    P	1
    T	1
    T	3

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Grouping field with same item

    In your query you're grouping by both Field1 & Field2 so the query will return all unique combinations of both fields (eg T:1, T:3)

    Assuming you're looking to Sum Field2 by Field1 (ie a SUMIF) then:

    Code:
    SELECT Table1.Field1, SUM(Table1.Field2)
    FROM Table1
    GROUP BY Table1.Field1

  3. #3
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    107

    Re: Grouping field with same item

    Thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0