#分组获得每个机柜里服务器占用的机架总数,如552807e6-b428-4184-b219-ae368c68ddb3占用4个

mysql> select cabinet_uuid, count(host_uuid) from rack where not host_uuid is NULL group by cabinet_uuid;
+--------------------------------------+------------------+
| cabinet_uuid | count(host_uuid) |
+--------------------------------------+------------------+
| 552807e6-b428-4184-b219-ae368c68ddb3 | 4 |
| 55ce78c0-1c2c-4d34-b383-4028fe45a2fa | 7 |
| 6662c7d9-1cd7-426b-8616-5190c434bc1e | 21 |
| 6b293326-00d0-4d59-9fd9-5c18273fcbcb | 2 |
| 77b86411-93d8-4af8-afd1-08ee5f90435d | 11 |
| 8f233310-cf75-457b-b7c4-4476e48cfab2 | 8 |
| 92da441c-54bf-4e9f-8b96-4e53cdb6dee4 | 19 |
| a3b6ebdf-7c6b-4571-b079-e7bcef662c4e | 14 |
| a7d76dd6-bbf9-4cf8-a1f9-40697a95f03f | 17 |
| e3b18a11-b542-4dbd-955f-f2d2f38e901b | 15 |
+--------------------------------------+------------------+
#机柜552807e6-b428-4184-b219-ae368c68ddb3里有2u服务器1台,1u服务器2台,也就是说2u服务器有2条一样的host_uuid,使用DISTINCT去重,得到每机柜准确的设备数

mysql> select cabinet_uuid, count(DISTINCT host_uuid) from rack where not host_uuid is NULL group by cabinet_uuid;
+--------------------------------------+---------------------------+
| cabinet_uuid | count(DISTINCT host_uuid) |
+--------------------------------------+---------------------------+
| 552807e6-b428-4184-b219-ae368c68ddb3 | 3 |
| 55ce78c0-1c2c-4d34-b383-4028fe45a2fa | 4 |
| 6662c7d9-1cd7-426b-8616-5190c434bc1e | 14 |
| 6b293326-00d0-4d59-9fd9-5c18273fcbcb | 2 |
| 77b86411-93d8-4af8-afd1-08ee5f90435d | 7 |
| 8f233310-cf75-457b-b7c4-4476e48cfab2 | 5 |
| 92da441c-54bf-4e9f-8b96-4e53cdb6dee4 | 12 |
| a3b6ebdf-7c6b-4571-b079-e7bcef662c4e | 9 |
| a7d76dd6-bbf9-4cf8-a1f9-40697a95f03f | 13 |
| e3b18a11-b542-4dbd-955f-f2d2f38e901b | 11 |
+--------------------------------------+---------------------------+

最新文章

  1. jQuery-1.9.1源码分析系列(十一) DOM操作续——克隆节点
  2. 微信小程序-上传下载
  3. A Tour of Go Type conversions
  4. PV(访问量)、UV(独立访客)、IP(独立IP) (转)
  5. C语言移位运算符
  6. How to deploy openbr on linux server very shorly---- linuxmint13/ubuntu12.04 AMD64/debian7
  7. Qt5:不规则按钮的实现---通过贴图实现
  8. 详解功能版本管理之使用eoLinker
  9. 轻松学习Asp.net中的控件
  10. Android SDK下载失败的解决方法
  11. servlet是线程安全的么
  12. Unable to handle kernel paging request at virtual address
  13. PAT基础6-10
  14. redis哨兵模式,数据尽量少的丢失
  15. NYOJ 85:有趣的数(打表,规律)
  16. as2 删除层级影片问题
  17. 第十章 优先级队列 (a1)需求与动机
  18. 第78讲:Type与Class实战详解
  19. L1-050 倒数第N个字符串
  20. 剑指offer-第一个只出现一次的字符-字符串和数组

热门文章

  1. 我的web安全工程师学习之路——规划篇
  2. Subversion Server Edge的安装使用
  3. ORA-14517: Subpartition of index "string.string" is in unusable state
  4. 安装openstack时遇到的错误
  5. linux下WordPress安装
  6. spring aop 原理学习
  7. java多线程(二)
  8. Android中当前Activity跳转到当前Activity页面
  9. nginx 访问路径配置
  10. 深入学习webpack(二)