none
how to join data from 2 different groups that reside on the same table RRS feed

  • Question

  •   Hello

    Suppose that I have a table like this


    ParName  !  Val1!  Val2 !

       A                b        j              
       A                o        p              
       A                j         l     
       B                p        h    
       A                j         k
       A                k        p
      

     
    I would like to get a table where  the data of A and B stay on the same line when the datetime is inside the same range (example the same day)


    so i would like to get something 


    !  A_Val1!  A_Val2 !  B_Val1!  B_Val2 !

            xx        xx
            hh        hh
            kk        kk        ii        ii
            pp        pp       jj        jj
            gg        gg
            kk        kk

    how can i do this in  in LINQ?
    Saturday, January 17, 2009 7:19 AM

All replies

  • If you perform a grouping, you can get a result set that contains the key (date) and then a collection of items that correspond to that key (your values). This is one of the advantages that LINQ has over standard TSQL in that it can return heirarchical structures even if the underlying source is flat.

    You should be able to find an aggregate example in the samples online easily enough. Since you didn't specify the language you're working in I don't want to send an example because the grouping syntax in VB and C# are significantly different.

    Jim Wooley
    www.ThinqLinq.com
    http://www.LinqInAction.net - "LINQ In Action", The book is now available. Don't wait for the movie
    Saturday, January 17, 2009 8:32 PM
    Moderator