select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
where vccommend=1 order by dtdatelist desc 我想查询vcpuid 字段不重复的记录,不知道怎么用子查询,谢谢.(oracle)

解决方案 »

  1.   

    select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1
    and vcpuid in (select vcpuid ,count(*) from tbproductlist group by vcpuid having count(*)=1 ) order by dtdatelist desc
      

  2.   

    and vcpuid in (select vcpuid ,count(*) from
    这个地方有两个字段,不行的,只能是and vcpuid in (select vcpuid from
      

  3.   

    and rowid in (
      select max(rowid) from tbproductlist group by vcpuid 
    )
      

  4.   

    select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1
    and vcpuid in (select vcpuid from tbproductlist group by vcpuid having count(*)=1 ) order by dtdatelist desc
      

  5.   

    select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1 and vcpuid in 
    (select vcpuid from 
       (select distinct vcpuid,count(*) from tbproductlist group by vcpuid 
          having count(*) = 1))
    order by dtdatelist desc还可以用. select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1 and not exists(
      select 'x' from tbproductlist b where a.vcpuid  = b.vcpuid and a.rowid <> b.rowid)
    order by dtdatelist desc还有其它方法. 比如用两个表并联. 很多方法的. 建议: 若是平时一次性使用, 建立建立中间表, 这样速度会快.
      

  6.   

    select a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1
    and vcpuid in (select vcpuid ,count(*) from tbproductlist group by vcpuid having count(*)=1 ) order by dtdatelist descorselect a.vcplid, a.vcpuid,a.vcproductname,a.vcproductimage,a.vcwaycode from tbproductlist a
    where vccommend=1
    and vcpuid in (select distinct vcpuid from tbproductlist) order by dtdatelist desc