日期:2014-05-16 浏览次数:20891 次
mysql> SELECT * FROM `ti_host` ; +------+--------+----------+------------+---------+--------------+------------+ -----------------+--------+--------+-----------+--------------+----------+----- ---------+-------------------+--------------+------------------+--------------- -+----------------+ | MOID | HOSTSN | HOSTNAME | CPUCORENUM | CPUDESC | CPUFREQUENCY | HOSTSTATUS | MANAGEDIPADDRESS | MEMORY | OS | OSVERSION | AGENTVERSION | HOSTTYPE | TOTA CAPACITY | TOTALCAPACITYUNIT | USEDCAPACITY | USEDCAPACITYUNIT | phisicalMemSiz | virtualMemSize | +------+--------+----------+------------+---------+--------------+------------+ -----------------+--------+--------+-----------+--------------+----------+----- ---------+-------------------+--------------+------------------+--------------- -+----------------+ | 1 | 234 | 234 | 234 | 234 | 234 | 1 | 10.27.81.131 | 324 | 234234 | 1 | 234 | 234234 | 2342 4 | 234 | 234 | 234 | 234 | 234 | | 2 | 234 | 234 | 234 | 23 | 423 | 0 | 10.27.81.131 | 345 | 345 | 1 | 345 | 234 | 234 | 234234 | 2342 | 23423 | 424 | 234 | +------+--------+----------+------------+---------+--------------+------------+ -----------------+--------+--------+-----------+--------------+----------+----- ---------+-------------------+--------------+------------------+--------------- -+----------------+ 2 rows in set (0.00 sec) mysql> SELECT COUNT(*),SUM(IF(hoststatus=0,1,0)), SUM(IF(hoststatus=1,1,0)), -> SUM(IF(hoststatus=2,1,0)) -> FROM `ti_host`; +----------+---------------------------+---------------------------+----------- ---------------+ | COUNT(*) | SUM(IF(hoststatus=0,1,0)) | SUM(IF(hoststatus=1,1,0)) | SUM(IF(hos status=2,1,0)) | +----------+---------------------------+---------------------------+----------- ---------------+ | 2 | 1 | 1 | 0 | +----------+---------------------------+---------------------------+----------- ---------------+ 1 row in set (0.00 sec) mysql>
------解决方案--------------------
mysql> select * from ti_host; +------+--------+----------+------------+---------+--------------+------------+------------------+--------+--------+-----------+--------------+----------+---------------+-------------------+--------------+------------------+-----------------+----------------+ | MOID | HOSTSN