Results 1 to 5 of 5
  1. #1
    johnbest is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    9

    Post need help on group by query

    hello,



    I have a table with following structure and data


    field1 field2 field3
    ----- ----- -----
    A B 1
    A B 2
    X Y 1
    P Q 3
    P Q 4

    and the Output required is

    field1 field2 field3
    ----- ----- -----
    A B 1,2
    X Y 1
    P Q 3,4


    Query please... ?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    Doubt query alone will do that. Could there be more than 2 associated records? Review: http://allenbrowne.com/func-concat.html
    Last edited by June7; 02-03-2014 at 12:10 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    johnbest is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    9
    dear jun7,

    thanks a lot for the reply

    well can i get the following output ?

    field1 field2 field3
    ----- ----- -----
    A B 1
    A B 2
    P Q 3
    P Q 4

    only those records where field1 and field2 both values are same ?

    this only will be sufficient for me.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    Try:

    SELECT * FROM tablename WHERE DCount("*","tablename","field1='" & [field1] & "' AND field2='" & [field2] & "'")>1;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    johnbest is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    9
    Dear June7

    thanks a lot

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Report Group - Show empty Group
    By crimedog in forum Reports
    Replies: 2
    Last Post: 12-30-2013, 01:06 AM
  2. Replies: 0
    Last Post: 02-25-2013, 04:43 PM
  3. Replies: 2
    Last Post: 06-21-2012, 07:40 PM
  4. Group title carrying forward to next group
    By Amandasr12 in forum Reports
    Replies: 3
    Last Post: 06-06-2012, 02:13 PM
  5. query group by over another group by?
    By gap in forum Queries
    Replies: 2
    Last Post: 07-04-2011, 12:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums