select no from 表 group by no having count(*)=1

解决方案 »

  1.   

    或:
    select no from 表 group by no having sum(1)=1
      

  2.   

    再问一句having count(*) = 1

    having count(no) = 1有什么区别?
      

  3.   


    select no
    from table
    group by no
    having  count(bh) =1
      

  4.   

    select no
    from table
    group by no
    having  count(no) =1
      

  5.   

    为什么select * 的时候会出错?
    怎样同时选出其他字段?
    我不想只要这一个字段,这样没有意义啊。
      

  6.   

    select no from 表 group by no having count(*)=1or select * from 表 aa where (select count(*) from 表 where aa.no=表.no)=1
      

  7.   

    create table f_newinsurance 
      (
        sign_date date, #签单日期
        sign_date_id integer, #签单日期ID 
        customer_id integer not null , #客户ID 
        gr_tt_indicator char(4), #个人团体标志
        policy_id integer not null , #保单ID 
        policyno varchar(20), #保单号
        start_date date, #起保日期
        end_date date, #止保日期
        sht_indicator char(6), #短期险标志
        indorno char(20), #批单号
        indor_id integer, #批单ID 
        character_id integer, #特性ID 
        vehtype_id integer, #车型ID 
        insno_id integer not null , #险种ID 
        maker_id integer not null , #经办人ID 
        agent_id integer, #代理点ID 
        busitype_id integer not null , #展业方式ID 
        driver1_id integer, #第一驾驶员ID 
        driver2_id integer, #第二驾驶员ID 
        vehicle_id integer, #车辆信息ID 
        new_indicator char(4), #新保续保标志
        newprice_ind char(10), #新车购置价分段
        veh_age smallint, #车龄
        doctype_id integer not null , #单证类型
        thd_ins_id integer, #三者限额ID 
        risk_indicator char(10) not null , #高风险标志
        thd_indicator char(10), #单保三者标志
        busi_num integer not null , #业务笔数
        insu_num integer not null , #承保数量
        policy_sum decimal(16,2) not null , #保单保额(主险保额之和)
        insu_sum decimal(16,2) not null , #保险金额(单险种保额)
        deposit decimal(16,2) not null , #储金
        premium decimal(16,2) not null , #保险费
        return_prem decimal(16,2) not null , #安返退费
        time_stamp datetime year to second not null , #时间戳
        cx_flag char(1) #车险标志
      );表是这样的,选择依据policyno那一列。
      

  8.   

    select * from 表 where no in (select no from 表 group by no having sum(1)=1)