SELECT with GROUP BY can be used as an alternative to SELECT DISTINCT. Pranay Rana's example is essentially equivalent to
SELECT DISTINCT UserName, Departmentid FROM user
If you want an example where the preference of GROUP BY over DISTINCT is justified, here's one. Say, you want to return items that only occur once in a table:
SELECT Item
FROM atable
GROUP BY Item
HAVING COUNT(*) = 1
