Databases · Middle · Question 32 of 75
What is COUNT(*) FILTER (WHERE status = 'paid') used for?
- 1Counting rows that have no status
- ✓Correct answer: Counting only matching rows inside an aggregate, so one query can return several counts
- 3Filtering the whole result before counting
Explanation
For example COUNT(*) FILTER (WHERE status = 'paid') AS paid, COUNT(*) FILTER (WHERE status = 'new') AS new in a single pass.