About 50 results
Open links in new tab
  1. Count number of records returned by group by - Stack Overflow

    Jun 16, 2016 · The group by doesn't change the number of rows though. 1 + 1 + 2 (in your example) will be the number of rows in the table. Are you looking for 3? The number of distinct groups?

  2. sql - How to use count and group by at the same select statement ...

    Apr 27, 2010 · I have an SQL SELECT query that also uses a GROUP BY, I want to count all the records after the GROUP BY clause filtered the resultset. Is there any way to do this directly with …

  3. sql - Execute count (*) on a group-by result-set - Stack Overflow

    Mar 22, 2012 · One is to group everything up in a sub query, then count those distinct rows (Christian Nunciato's answer). The second is to combine the multiple fields and count distinct values of that …

  4. SQL select with GROUP BY and COUNT? - Stack Overflow

    Jul 26, 2021 · SELECT ProductID, CustomerID, COUNT(*) as C FROM Purchases GROUP BY ProductID, CustomerID HAVING C > 100 ORDER BY C DESC Better still, how would I go about …

  5. sql server - SQL count number of groups - Stack Overflow

    May 15, 2015 · sql-server group-by sql-server-2012 edited May 15, 2015 at 5:21 Ajay2707 5,828 6 44 61

  6. Using group by on two fields and count in SQL - Stack Overflow

    Apr 30, 2012 · Using group by on two fields and count in SQL Asked 13 years, 7 months ago Modified 2 years, 10 months ago Viewed 266k times

  7. SELECT number of groups resulted from a GROUP BY query

    Nov 26, 2015 · SELECT count(*) FROM ( SELECT count(*) FROM MyTable WHERE Col2 = 'x' GROUP BY Col1 ) Unfortunately, this query is not valid: Incorrect syntax near ')'.. Note: I want to get exactly …

  8. SQL group by count where count greater than - Stack Overflow

    Jan 16, 2017 · I have this SQL that counts the groups, but I want to say where the count is greater than 1, can anyone help as it doesn't currently work? select Code, Qty, Count(Qty) from Product where …

  9. sql server - SQL Group by Count of Counts - Stack Overflow

    Dec 1, 2011 · SELECT COUNT( [Id]) as [Count Of Register], Tag as [Tag] FROM [Members] Group By Tag Order By [Count Of Register] Desc; Returned table is like this:

  10. sql - Selecting COUNT (*) with DISTINCT - Stack Overflow

    Count(DISTINCT program_name) AS [Count], FROM cm_production WHERE push_number = @push_number GROUP BY program_type DISTINCT COUNT(*) will return a row for each unique …