select memberno, max(team1_cnt) team1_cnt, max(team2_cnt) team2_cnt, max(team1_firstday) team1_firstday, max(team1_lastday) team1_lastday, max(team2_firstday) team2_firstday, max(team2_lastday) team2_lastday from ( select memberno, count(*) team1_cnt, 0 team2_cnt, min(startday) team1_firstday, max(startday) team1_lastday, null team2_firstday, null team2_lastday from t_team1 group by memberno union all select memberno, 0 team1_cnt, count(*) team2_cnt, null team1_firstday, null team1_lastday, min(startday) team2_firstday, max(startday) team2_lastday from t_team2 group by memberno ) group by memberno 위와 같이 쿼리를 작성하였는데, 쿼리의 결과는 맞게 나오지만, group by 절을 두번 중복하여 사용하여 깔끔하게 작성되었다는 생각이 들지 않습니다. 고수님들의 조언 부탁드립니다.