COUNTで条件に当てはまるものがいくつあるか、つまり行の数を取得する。
https://www.postgresql.jp/docs/9.4/functions-aggregate.html
postgresdb1=# SELECT * FROM products;
id | name | price | tax | quantity | discount
----+------------+--------+-------+----------+----------
1 | ペン | 100.00 | 10.00 | 50 | 5.00
2 | ノート | 200.00 | 10.00 | 10 | 3.00
3 | ペンケース | 250.00 | 10.00 | 10 | 3.00
3 | 消しゴム | 50.00 | 10.00 | 5 | 8.00
(4 行)
postgresdb1=# SELECT COUNT(*) FROM products;
count
-------
4
(1 行)
postgresdb1=#行の数を取得。