How to Write SQL to Group By Column and Using Distinct