Supressing repeating values?

  • Probably a silly question, but I have to ask:

    Is there a way to supress repeating values in a column on a join between tables where the joined table has more than one matching foreign key value?

    Example:
    Create Table1 (
    T1_key int,
    T1_value int
    )
    Create Table2 (
    T2_key int,
    T1_key, int,
    T2_value int
    )
    If Table1 has the follwing values:
    T1_key  T1_Value
    ------  --------
    1       1
    2       2
    Table2 has the following values:
    T2_key  T1_key  T2_value
    ------  ------  --------
    1       1       365    
    2       1       42
    3       2       69
    4       2       42
    5       2       808
    If I query like this:
    SELECT T1_key, T1_value, T2_value
    FROM Table1 T1 INNER JOIN
    Table2 T2 ON T1.T1_Key = T2.T1_Key
    WHERE T1.T1_key = 2
    The result set looks like this:
    T1_key  T1_value    T2_value
    ------  --------    --------
    2       2           69
    2       2           42
    2       2           808
    What I want is for it to look like this:
    T1_key  T1_value    T2_value
    ------  --------    --------
    2       2           69
                        42
                        808
                        
    NULLS or Empty strings would be fine for the "missing" values.  Any suggestions?                    
    
  • something similar was addressed a few days ago and the general consensus was that this should be done client-side...however, Lee did come up with a solution...

    lee's solution







    **ASCII stupid question, get a stupid ANSI !!!**

  • Sushila,

    Thanks for the pointer to the oh-so-recently discussed solution...that's what I get for posting at the end of the day without checking the threads first.

    Lee's solution may work for me, it's very clever.  Thanks again.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply