我可以一起使用COUNT()和DISTINCT吗?

时间:2010-12-19 16:12:42

标签: sql mysql

我想计算一个mysql表中的行数,而不是包含重复的条目,

我可以将distinctcount()一起使用吗?

4 个答案:

答案 0 :(得分:43)

不确定

SELECT COUNT(DISTINCT column) FROM table;

答案 1 :(得分:11)

您需要的是以下内容:

SELECT field_type_name, count(*) FROM fields GROUP BY field_type_name;

这会给你这样的东西:

image   14
string  75
text     9

答案 2 :(得分:5)

 SELECT COUNT(DISTINCT field) from Table

See this

答案 3 :(得分:0)

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/service-worker.js').then(function(reg) {
    // updatefound is fired if service-worker.js changes.
    reg.onupdatefound = function() {
      var installingWorker = reg.installing;

      installingWorker.onstatechange = function() {
        switch (installingWorker.state) {
          case 'installed':
            if (navigator.serviceWorker.controller) {
              // At this point, the old content will have been purged and the fresh content will
              // have been added to the cache.
              // It's the perfect time to display a "New content is available; please refresh."
              // message in the page's interface.
              console.log('New or updated content is available.');
            } else {
              // At this point, everything has been precached.
              // It's the perfect time to display a "Content is cached for offline use." message.
              console.log('Content is now available offline!');
            }
            break;

          case 'redundant':
            console.error('The installing service worker became redundant.');
            break;
        }
      };
    };
  }).catch(function(e) {
    console.error('Error during service worker registration:', e);
  });
}