意思大概是这样的
select count(distinct na,nb) from table

解决方案 »

  1.   


    --不太明白你的意思 是这个?
    select count(*) from table group by na,nb
    --或者是?
    select count(distinct na) from table
    union
    select count(distinct nb) from table
      

  2.   

    SELECT COUNT(*) FROM (
      SELECT DISTINCT na, nb FROM table
      ) t;
      

  3.   

    select count(*) from table group by na,nb
      

  4.   

    那就分组后算统计数:select count(*) from table group by na,nb
      

  5.   


    select count(distinct na || nb) from table
    你好,如果你只关心count数这样应该可以
      

  6.   

    注意了,如果你要的是计算(a 列和 b列的组合条数 重复的不能计算在内)的条数,这个就可以
    select count(*),na,nb from table group by na,nb;
    但如果你要的是显示(a 列和 b列的组合条数 重复的不能计算在内)的所有记录,那么
    select distinct na,nb from table; 就可以了。
      

  7.   


    select count(distinct na||nb) from table
      

  8.   

    --你写的有语法问题
    select count(*) from table group by na,nb
    --or
    select count(*) from (select distinct na,nb from table)
      

  9.   

    我想我明白LZ的意思了,用这个
    SELECT COUNT(*) FROM (
    SELECT DISTINCT na, nb FROM table
    ) t;
      

  10.   

    比如用在sum时可能需要SUM(A)/count(distinct na||nb)
      

  11.   


    select count(1)
    from (select na,nb from table group by na,nb)
      

  12.   

    18楼的第二个
    select count(*) from (select distinct na,nb from table)
    第一个少套了一层
      

  13.   

    想了想,也可以用||,不过得加个数据中不会出现的字符加在中间,避免上面所说的错误.
    比如 select distinct na||'-'||nb from table
      

  14.   

    SELECT COUNT(1) FROM 
     (SELECT DISTINCT NA,NB from table) a;
      

  15.   

    哎 还是在itpub的大牛给解决了
    with t as
    (
    select 1 as a, 5 as b from dual
    union all
    select 1 as a, 5 as b from dual
    union all
    select 2 as a, 8 as b from dual
    union all
    select 1 as a, 7 as b from dual
    )
    SELECT COUNT(COUNT(*)) FROM t GROUP BY a,b;