I think this is simple question but google only gives me select and count results.
I’m wondering if it is possible to select from a table with a limit and count all the rows that would normally be affected by the query.
For example:
I got 100 rows in table cars and I select the first 20 I want the count how many cars there are in the cars table in one query.
Thanks in advance
If I understand your need (I understand it to be that you want the result of your limited query plus the number of rows in the full table), this can be done with a
SELECTsubquery, or with aJOINagainst a subquery. Since you only expect one row back from the count query, you can use a cartesian join (with noONclause). The count of all rows then appears as the same value for each column.Would produce a result like