Reputation: 31
I have a table with 12 columns.
I need a query for computing COUNT(*)
and selecting all the columns.
I mean I want to have these two queries just in one query:
select *
from mytable
where OneOfTheColumns = something;
select COUNT(*)
from mytable
where OneOfTheColumns = something;
Conditions and tables are the same.
Can I do this?
Thanks a million.
Upvotes: 0
Views: 2337
Reputation:
You can use a window function for that
select *,
count(*) over () as total_count
from mytable
where OneOfTheFields = something;
Upvotes: 3