select  rownum, 'ckqy5' as layer, 'Default' as tag, 'POLYGON' as type, c.smid, c.name as title, c.examincode, x.roadnames as road from 交叉点 x left join ckqy5 c on  x.ckqy5id = c.examincode where c.examincode like'%%' and x.roadnames like '%%,%%' and rownum <= 10 group by();想要得到的结果是如果title,examincode, road这三个字段全部相同的话只显示其中一条

解决方案 »

  1.   

    select rownum,
           'ckqy5' as layer,
           'Default' as tag,
           'POLYGON' as type,
           c.smid,
           c.name as title,
           c.examincode,
           c.roadnames as road
      from (
    select distinct c.name as title,
           c.examincode,
           x.roadnames as road
      from 交叉点 x
      left join ckqy5 c on x.ckqy5id = c.examincode
     where c.examincode like '%%'
       and x.roadnames like '%%,%%'
       and rownum <= 10
     group by name,examincode,roadnames
     )c