I have a simple table from which I have to do a select, however it has to be something like this:

Table example

```
StatusID    StatusCode    BrandID    StatusName

1           1             1000       First Status
2           2             1000       Second Status
3           3             1000       Third Status
4           1             2000       First Custom Status

```

I need a select query where BrandID = 1000 to output this:

```
StatusID    StatusCode    BrandID    StatusName

1           1             1000       First Status
2           2             1000       Second Status
3           3             1000       Third Status

```

I need a select query where BrandID = 2000 to output this:

```
StatusID    StatusCode    BrandID    StatusName

4           1             2000       First Custom Status
2           2             1000       Second Status
3           3             1000       Third Status

```

In Other words, if BrandID is default (1000) I need to select all rows belonging to this BrandID, however if BrandID is 2000 I need to select all rows belonging to this BrandID + rows with default BrandID if there is no BrandID 2000 for that particular StatusCode.
I hope this is good enough explanation. This is the quer I've been working on

```
SELECT  *

FROM        table

GROUP BY    StatusCode
HAVING  BrandID = 2000

```

Obviously it doesn't work as intended.