Query help - manipulating data from just one table

  • Dear all,

    I am building a query from just a single table and would really appreciate any help. Thanks in advance.

    Table A

    -------

    ID#Value#Group

    ---------------

    1#Value1#Grp1

    2#Value2#Grp2

    INTO a temp table

    Temp table

    -----------

    ID#Value

    --------

    1#Value1-Grp1

    2#Value1-Grp2

    3#Value2-Grp1

    4#Value2-Grp2

  • Can you explain as what result set you are looking. I assume you need some kind of cross join.

     


    Kindest Regards,

    Amit Lohia

  • Thanks for the reply. Looking at my example again, I thought I had a poor one so I will do another.

    Table1

    ID#TypeName#Type

    -------------------

    1#Maths#Subject

    2#Science#Subject

    3#Percent10#Percentile

    4#Percent50#Percentile

    Using Table 1, I would need to write a script to write into a temp table (#temp) which is the result set.

    #temp

    ID#Name

    --------

    1#Maths-Percent10

    2#Maths-Percent50

    3#Science-Percent10

    4#Science-Percent50

    The type "name" would be a concatenation between the combination of subjects and percentiles.

    Thanks in advance.

  • SELECT * FROM Table1 A

    JOIN Table1 B ON A.Type<>B.Type

    AND A.Type = 'Subject'

    SELECT * FROM Table1 A

    JOIN Table1 B ON B.Type='Percentile'

    AND A.Type = 'Subject'

    You can do in other ways also

     


    Kindest Regards,

    Amit Lohia

  • Thanks so much!

Viewing 5 posts - 1 through 4 (of 4 total)

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