写了这样一个sql语句、有人说这么写运行效率会太低、因为表的数据比较庞大、是这样的吗
select count(distinct(営業日)) from HST_台データ1 where()
如果是的话、请大家帮我想想好的SQL语句、能实现与此相同的功能的
谢谢

解决方案 »

  1.   

    简单测试; SQL> select count(distinct owner) from test_tab;COUNT(DISTINCTOWNER)
    --------------------
                      29Executed in 0.51 secondsSQL> select distinct count(owner) from test_tab;COUNT(OWNER)
    ------------
          222108Executed in 0.371 secondsSQL> select count(distinct object_name) from test_tab;COUNT(DISTINCTOBJECT_NAME)
    --------------------------
                         38314Executed in 1.472 secondsSQL> select distinct count(object_name) from test_tab;COUNT(OBJECT_NAME)
    ------------------
                222108Executed in 0.38 seconds发现一般情况下distinct count(X)比count(distinct X) 要快
      

  2.   

    SQL> select count(distinct owner) from test_tab;SQL> select distinct count(owner) from test_tab;这两个语句的查询结果不一样,你可以试一下.包子说的是错的