Question: I have the following DataSet on a SSRS report:

```
SELECT
  VariationCode.Code
  ,VariationCoding.Comment
  ,VariationCoding.SubmissionDate
  ,VariationCoding.Id
FROM
  VariationCode
  INNER JOIN VariationCoding
    ON VariationCode.Id = VariationCoding.VariationCodeId
WHERE VariationId = @VariationId

```

I am showing static headers on the left and data on the right which works fine but I'm struggling to group the results by ID and show them as a separate table per grouping.

Grouping the row by parent using VariationCoding.Id shows one table with no grouping at all. I suspect having the headers on the left is the problem since most solutions I've seen have the headers on top.

How can I show static headers on the left and group the results by VariationCoding.Id in such a way that each result will be displayed in a separate table?

Answer: 
Consider the values you can achieve with 2 bits:

```
00 : 0
01 : 1
10 : 2
11 : 3

```

There are 4 of them, 2 to the power of 2.  

But the highest value is not 4, it is 3.  

The highest value is 2 to the power of 2 minus 1. I.e. in your representation 

2^2-1  

or 22-1

Add a bit and you get twice the number, by adding

```
100 : 4
101 : 5
110 : 6
111 : 7

```

Total number 8, but highest number 7.

So the "-1" is because always the first of the total of 2n is used for 0,  

the 2nd is used for 1, the 3rd is used for 2.  

In the end (2n)th one is not available for 2n, it is already used for 2n-1.
Adding to @Yunnosch's excellent explanation on unsigned numbers, almost all modern computers use "two's complement" to represent signed binary integers.
In two's complement, the most significant bit is used as the "sign bit" and bits are the complement of absolute value of the number + 1. So for the 3 bit example, while the range for unsigned values is 0 to 7, the range for signed values is -4 to 3:

```
100 : -4
101 : -3
110 : -2
111 : -1
000 :  0
001 :  1
010 :  2
011 :  3

```

Notice that for signed numbers the range of negative numbers is one greater than the range of positive numbers. That's because, while in number theory, `0` is neither positive or negative, in binary representation, `0` has to be either negative or positive. Because it has the most significant bit cleared, `0` is part of the positive number domain, so that leaves one less positive number available.