SQL Aggregation queries using Group By, Sum, Count and Having