About 881,000 results
Open links in new tab
  1. How to count occurrences of a column value efficiently in SQL?

    In the second query, there's embedded group-by that potentially greatly reduces the number of rows. Try adding DISTINCT to the first query: "select DISTINCT id, age, count (*) over …

  2. sql server - SQL count rows in a table - Stack Overflow

    Mar 7, 2015 · I need to send a SQL query to a database that tells me how many rows there are in a table. I could get all the rows in the table with a SELECT and then count them, but I don't like …

  3. sql - Multiple COUNT () for multiple conditions in one query …

    Sep 27, 2013 · If you want the result to be in one row you can use:

  4. sql - Select count (*) from multiple tables - Stack Overflow

    How can I select count(*) from two different tables (call them tab1 and tab2) having as result: Count_1 Count_2 123 456 I've tried this: select count(*) Count_1 from schema.tab1 union all

  5. How can I get multiple counts with one SQL query?

    Note that as an alternative to distinct, as I have made the correction, you can also/better use group by with the benefit of replacing an entire nested query with a simple count(*) as @Mihai …

  6. sql - Is it possible to specify condition in Count ()? - Stack Overflow

    Is it possible to specify a condition in Count()? I would like to count only the rows that have, for example, "Manager" in the Position column. I want to do it in the count statement, not using WH...

  7. 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 …

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

    This gets me partway there, but it's counting all the program names, not the distinct ones (which I don't expect it to do in that query). I guess I just can't wrap my head around how to tell it to …

  9. Finding and deleting duplicate values in a SQL table

    Jul 28, 2019 · It uses a common table expression (CTE) and a partition window (I think these features are in SQL 2008 and later). This example finds all students with duplicate name and …

  10. Using DISTINCT and COUNT together in a MySQL Query

    Jun 16, 2009 · SELECTING DISTINCT PRODUCT AND DISPLAY COUNT PER PRODUCT for another answer about this type of question, this is my way of getting the count of product …