How to Select the First/Least/Max Row per Group in SQL