PostgreSQL: Count total rows when range is empty

PHOTO EMBED

Mon Aug 29 2022 16:55:57 GMT+0000 (UTC)

Saved by @marcopinero #sql

WITH cte AS (
   SELECT *
   FROM   m_paciente mp 
   WHERE  apellido like 'P%'
   )
SELECT *
FROM  (
   TABLE  cte
   ORDER  BY apellido, nombre
   LIMIT  10
   OFFSET 190
   ) sub
RIGHT  JOIN (SELECT count(*) FROM cte) c(full_count) ON true;
content_copyCOPY