Lokesh K

Lokesh K

  • NA
  • 148
  • 41.3k

How to Group with Matching records and give name to the grp

Aug 29 2018 1:25 PM
Hi,
i'm strucked with this place, where i need to group the matched records to a group and give name to the group like shown below.
 
Case 1:  
Id         Number         Occurrence
1            1234               New
2            2345               1234
3            3456               2345
4            4567               New
5            5678               4567 
 
Here...Numbers are mapped with Occurrence place 
 
Case 2
Id            Number           Occurrence
1               1234                    New
2               2345                   1234
3              3456                    1234
4              4567                    1234
 
Here.... also Numbers are mapped with Occurrence place
 
My Output should be like shown below for Case 1:
 
Solution for Case 1:
Id           Number        Occurrence      OccurrenceTimes
1           1234                 New                     P1
2           2345                1234                     P1
3           3456                2345                     P1
4           4567                New                      P2
5           5678                4567                     P2
 
 
Solution for Case 2
Id           Number        Occurrence      OccurrenceTimes
1           1234                   New                     P1
2           2345                   1234                    P1
3           3456                   1234                    P1
4           4567                   1234                    P1
 
Pls anyone suggest for above Solution Cases. Using linq or???
 
Regards,
Lokesh 
 
 
 
 

Answers (1)