Select col1.row1, col2.row1, max(col3.row1) From col1 inner join col2 on ... Inner join col3... Group by col1.row1, col2.row1, col3.row1, COL12.ROW1 < COL3.ROW1 HAVING...