query aggregate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hbeer444
    New Member
    • Apr 2008
    • 1

    query aggregate

    Is there an easy way to use a query to join strings from different records of the same field

    ie with the following data

    record field1 field2

    r1 "dog" "big"
    r2 "dog" "strong"
    r3 "cat" "wimpy"

    I want query results:

    "dog" "big strong"
    "cat" "wimpy"



    hope the question is clear

    I have done vis basic functions but am not very efficient at them

    Thanks in advance
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by hbeer444
    Is there an easy way to use a query to join strings from different records of the same field

    ie with the following data

    record field1 field2

    r1 "dog" "big"
    r2 "dog" "strong"
    r3 "cat" "wimpy"

    I want query results:

    "dog" "big strong"
    "cat" "wimpy"



    hope the question is clear

    I have done vis basic functions but am not very efficient at them

    Thanks in advance
    [code=sql]
    Select field2 from Table where field1 = 'dog' order by field2
    [/code]

    You will probably have to do some concatonation with your results to get them in the form you want, but I believe that will be the query you are looking for.

    Looping through the results of this and adding them on to a string will basically give you what you need.

    To get the exact results from a single query though I think you will need to play around with the Select DISTINCT(field1 ) syntax.

    Comment

    Working...