我有一个查询,返回了644行数据,按照几列进行分组。我需要得到这些行的数量,即644。
以下是查询语句:
SELECT DISTINCT ho.ID,ho.honame,ho.ho_status,SUM(Properties.Value) as [sales value], COUNT(Properties.record_id) as [property count]
FROM HeadOffice ho INNER JOIN Properties ON Properties.head_office_code = ho.id
WHERE Somecondition
GROUP BY ho.ID,ho.honame,ho_status ORDER BY ho_status
尝试使用COUNT(*)
,将其包装在另一个查询中并删除GROUP BY
,但我无法获得'644'。 我最接近的是644行,全部包含'1'。这种情况可能吗?
select count(1) from (select distinct ID, honame, ho_status from HeadOffice) ignore
返回什么结果? - Sergey Kalinichenko