I want to select companies that contributes more in their business type code and group them by ***BTypeCode***. Select the top given number(e.g `Select Top (5) * from transactions`). The given number can be any integer number that is positive.

Table is like this

```
    | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
    +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
    | B40707194 | INDEPENDENT DEVELOPMENT  | 11        | 29,92  | -284,68   | 17,94  | 0        | -236,82 | -473,64         |
    | B40703250 | AQUA PLUMBING            | 5         | 0      | -661,31   | 0      | 0        | -661,31 | -1322,62        |
    | B30718409 | MM CONSULTING PTY LTD    | 23        | -0,79  | -2,63     |-0,47   | 0        |-3,89    | -7,78           |
    | B30711446 | S SULMAN & SEIDER        | 27        | -83,17 | 0         | -49,9  | 0        | -133,07 | -266,14         |
    | B30704656 | NAUMANN CONSTRUCTION     | 23        | 0      | -1,47     | 0      | 0        | -1,47   | -2,94           |
    | B30703609 | SWITCH ON MARKETING  CC  | 27        | -128,68| 0         | -77,2  | 0        | -205,88 | -411,76         |
    | B20733582 | MAINLINE CARRIERS BPK    | 11        | -19,45 | -87,5     | -11,66 | -6,24    | -124,89 | -249,78         |
    | B20729994 | MIDRAND HYDRAULICS CC    | 23        | -17,85 | -44,33    | -10,7  | 0        | -72,88  | -145,76         |
    | B20722395 | DOLPHIN  SUPERMARKET     | 5         | 57,04  | -76,65    | -442,22| -54,61   | 0       | -516,44         |
    | B20701738 | MEISES HALT FUELS        | 12        | -88,93 | -110,28   | 41,35  | 0        |0        | -157,86         |
    | B10737056 | PROTON INT REALTY        | 26        | 21,61  | -31,84    | 12,96  | 0        | 2,73    | 5,46            |
    | B10729301 | NED HERV GEMEENTE        | 23        | 3,31   | -5,7      | 1,98   | 0        |-0,41    | -0,82           |

```

And out put for top 1 suppose to be like this below

**BTypeCode : 5**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B40703250 | AQUA PLUMBING            | 5         | 0      | -661,31   | 0      | 0        | -661,31 | -1322,62        |

```

**BTypeCode : 11**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B40707194 | INDEPENDENT DEVELOPMENT  | 11        | 29,92  | -284,68   | 17,94  | 0        | -236,82 | -473,64         |

```

**BTypeCode : 12**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B20701738 | MEISES HALT FUELS        | 12        | -88,93 | -110,28   | 41,35  | 0        |0        |    -157,86         |

```

**BTypeCode : 23**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B20729994 | MIDRAND HYDRAULICS CC    | 23        | -17,85 | -44,33    | -10,7  | 0        | -72,88  | -145,76         |

```

**BTypeCode : 26**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B10737056 | PROTON INT REALTY        | 26        | 21,61  | -31,84    | 12,96  | 0        | 2,73    | 5,46            |

```

**BTypeCode : 27**

```
 | Bno       | BusinessName             | BTypeCode | BLe    | BInterest | BAdmin | BPenalty |TotalBus | TotalCollected
 +-----------+--------------------------+-----------+--------+-----------+--------+----------+---------+-----------------+
 | B30703609 | SWITCH ON MARKETING  CC  | 27        | -128,68| 0         | -77,2  | 0        | -205,88 | -411,76         |

```

My current code look like this but it not giving me what I want.

```
DateTime startMonth, endMonth;
long BTypeCode;
int Topnum;
var query = (from _transaction in _entities.Transactions
                                 join _cd in _entities.Organisations on _transaction.Bno equals _cd.Bno
                                 join btypecodes in _entities.BusinessTypeCodes on _transaction.BTypeCode equals btypecodes.BTypeCode
                                 where (_transaction.TransactionDate >= startMonth || startMonth == DateTime.MinValue)
                                       && (_transaction.TransactionDate <= endMonth || endMonth == DateTime.MaxValue)
                                       && (_transaction.BTypeCode == BTypeCode || BTypeCode < 0)
                                 group new { _transaction,btypecodes } by new
                                 {
                                     _transaction.Id,
                                     _transaction.Bno,
                                     _cd.BusinessName,
                                     _transaction.TransactionDate,
                                     _transaction.BTypeCode,
                                     btypecodes.Description
                                 } into grp
                                 orderby grp.Sum(e => e._transaction.TotalCollected)
                                 select new
                                 {
                                     TransactionId = grp.Key.Id,
                                     Bno = grp.Key.Bno,
                                     BusinessName = grp.Key.BusinessName,
  TransactionDate = grp.Key.TransactionDate,   
                              BLe = grp.Sum(sum => sum._transaction.BLe),                                     
                                     BInterest = grp.Sum(sum => sum._transaction.BInterest),
                                     BAdmin = grp.Sum(sum => sum._transaction.BAdmin),
                                     BPenalty = grp.Sum(sum => sum._transaction.BPenalty),
                                     TotalBus = grp.Sum(sum => sum._transaction.TotalBus),
                                     TotalCollected = grp.Sum(sum => sum._transaction.TotalCollected),
                                     TypeCode = grp.Key.BTypeCode + " - " + grp.Key.Description,
                                     BTypeCode = grp.Key.BTypeCode,
                                 }).Take(Topnumb);

```

Please help me.