SQLSELECT TB.CODE, TB.NAMEFROM TBINNER JOIN ( SELECT CODE, min(NAME) FROM TB GROUP BY CODE) GR ON GR.CODE = TB.CODEORDER BY GR.NAME, TB.NAME