About 10,000,000 results
Open links in new tab
  1. Understanding how WHERE works with GROUP BY and Aggregation

    FROM clause WHERE clause GROUP BY clause HAVING clause SELECT clause ORDER BY clause Using this order you will apply the filter in the WHERE prior to a GROUP BY. The …

  2. SQL - using alias in Group By - Stack Overflow

    SQL is implemented as if a query was executed in the following order: FROM clause WHERE clause GROUP BY clause HAVING clause SELECT clause ORDER BY clause For most …

  3. sql - How does GROUP BY work? - Stack Overflow

    May 30, 2017 · GROUP BY returns a single row for each unique combination of the GROUP BY fields. So in your example, every distinct combination of (a1, a2) occurring in rows of Tab1 …

  4. How to get list of values in GROUP_BY clause? - Stack Overflow

    In mysql, use SELECT id, GROUP_CONCAT(data) FROM yourtable GROUP BY id or use your custom separator: SELECT id, GROUP_CONCAT(data SEPARATOR ', ') FROM yourtable …

  5. How can I group time by hour or by 10 minutes? - Stack Overflow

    SELECT [Date] FROM [FRIIB].[dbo].[ArchiveAnalog] GROUP BY [Date] How can I specify the group period? I'm using MS SQL 2008. I've tried this, both with % 10 and / 10.

  6. How do I perform a GROUP BY on an aliased column in SQL Server?

    I'm trying to perform a group by action on an aliased column (example below) but can't determine the proper syntax. SELECT LastName + ', ' + FirstName AS 'FullName' FROM customers GRO...

  7. sql - How to combine GROUP BY and ROW_NUMBER? - Stack …

    Undoubtly this can be simplified but the results match your expectations. The gist of this is to Calculate the maximum price in a seperate CTE for each t2ID Calculate the total price in a …

  8. How to use count and group by at the same select statement

    Apr 27, 2010 · I think they mean if you put COUNT (DISTINCT town) in the WHERE clause. That is because it is an aggregate function and needs to be provided in the HAVING clause. This …

  9. How to use GROUP BY to concatenate strings in SQL Server?

    This type of problem is solved easily on MySQL with its GROUP_CONCAT() aggregate function, but solving it on Microsoft SQL Server is more awkward. See the following SO question for …

  10. sql - Select max value of each group - Stack Overflow

    @Craig wrong, this query works in all flavours of rdbms and returns the data as expected, since the OP was not after returning the entire record with the maximum value per group, but …