I have a query which returns 644 rows, grouped by several columns. I need to get a count of these rows, 644.
This is the query:
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
Despite trying COUNT(*), wrapping it in another query and removing the GROUP BY, I can’t get ‘644’ back. The closest I’ve come is 644 rows, all containing ‘1’. Is this possible?
The easy way to do it is thusly:
If you want the count plus your columns, use
over: