I would really appreciate some help with a query I am having difficulty with.
Here is an example of the data:

```
DEPT  FLAG   FLAG2  FLAG3

100    A             1
100    A      B  
201    A      1   
201    1      3
300           Z
301    5
301    2      3      FG

```

I need the following results: (distinct dept, with total count of flag, and flag2 that contains a value.) Using the data above, the results returned should look like:

```
dept  countFlag countFlag2 countFlag3

100      2         1            1
201      2         2            0
300      0         1            0
301      2         1            1

```

100 2, 1, 1 <--- for dept 100, there are two rows that contain a value in flag column and 1 that contains a value in flag2 and 1 that contains a value in flag 3. 

I hope this makes sense. Thanks in advance.