SELECT
DISTINCT COUNT(T2.F_VAL) AS F,
COUNT(DISTINCT T1.P_VAL) AS P
FROM
T1, T2
WHERE T1.P_KEY=T2.F_KEY
given following T1 and T2 tables:
T1
(
P_KEY INTEGER,
P_VAL VARCHAR(20)
)
P_KEY | P_VAL
--------------
1 | UK
2 | Russia
NULL | Ukraine
T2
(
P_KEY INTEGER,
F_KEY INTEGER,
F_VAL VARCHAR(20)
)
P_KEY | F_KEY | F_VAL
---------------------
1 | 1 | London
2 | 2 | Moscow
NULL | 2 | St. Petersburg
NULL | NULL | Kiev
Login in to like
Login in to comment