我是MYSQL的新手,但我试图从我已有的MYSQL select中获得计数。
非常多,我想计算项目的数量,然后按它们的位置分组它们.locationID然后显示locations.Name。从MYSQL查询获得计数
这是我有(有点乱)。这将获得5000MB以上的驱动器并显示它们。
Select DISTINCT
'C'
, computers.computerid
, computers.Name as ComputerName
, Convert(CONCAT(clients.name,' ',locations.name) Using utf8) As Location
, drives.`Size` as TestValue,0
FROM ((drives
LEFT JOIN Computers ON Computers.ComputerID=drives.ComputerID)
LEFT JOIN Locations ON Locations.LocationID=Computers.Locationid)
LEFT JOIN Clients ON Clients.ClientID=Computers.clientid
JOIN AgentComputerData on Computers.ComputerID=AgentComputerData.ComputerID
WHERE drives.`Size` > 5000 AND (1)
AND Computers.ComputerID NOT IN
(Select ComputerID from AgentIgnore Where AgentID=0);
预先感谢任何帮助,您可以给我。
非常好,这是方式更清洁,工作得很好,谢谢。 – Jeff 2011-05-06 12:49:47