How can I request all columns (*) in a table while at the same time counting all distinct items in a id_number column? (Learning SQL Thanks for your help)
How can I request all columns (*) in a table while at the same time counting all distinct items in a id_number column? (Learning SQL Thanks for your help)
You can use WITH to make a sub-query like:
WITH with_tbl_a AS
(SELECT * FROM tbl_a)
SELECT a.col_1, count(b.pk), etc...
FROM with_tbl_a
INNER JOIN tbl_b b ON a.fk = b.pk
Hope that it helps you.