By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE Table1 (Id int, Table1_Col VARCHAR (1));
INSERT INTO Table1 (Id, Table1_Col) VALUES
(1, 'A'),
(2, 'B'),
(3, 'C'),
(4, 'D'),
(5, 'E');
CREATE TABLE Table2(Id INT, Table1_Col VARCHAR (1), Table2_Col VARCHAR (10));
INSERT INTO Table2 (Id, Table1_Col, Table2_Col) VALUES
(1, 'A', 'Test');
6 rows affected
select T1.Table1_Col, Count(T2.Table2_Col) AS Table2_Col
from table1 t1
Left outer join table2 t2 on t1.Table1_Col = t2.Table1_Col
GROUP BY T1.Table1_Col
Table1_Col | Table2_Col |
---|---|
A | 1 |
B | 0 |
C | 0 |
D | 0 |
E | 0 |
Warning: Null value is eliminated by an aggregate or other SET operation.