SELECT statement with if ELSE MSSQL : I have a table looks like this:

    > `ref    doc` 
    > `ref001   3` 
    > `ref001   3` 
    > `ref002   1` 
    > `ref002   4` 
    > `ref002   1`

I want to use SELECT with IF ELSE STATEMENT similarly to this idea: 
`SELECT MAX(ref), if(ref=ref then MAX(doc)) else SUM(doc)` 

Sample output:

      ref001  3
      ref002  6
