Medio raro el query pero obtiene lo que necesitas :)
Código SQL:
Ver originalCREATE TABLE #temp
(
rut INT,
noc VARCHAR(3)
)
CREATE TABLE #temp2
(
rut INT,
nlic VARCHAR(3)
)
INSERT INTO #temp VALUES (15,'01')
INSERT INTO #temp VALUES (15,'02')
INSERT INTO #temp VALUES (16,'03')
INSERT INTO #temp2 VALUES (15,'L3')
INSERT INTO #temp2 VALUES (15,'L2')
INSERT INTO #temp2 VALUES (17,'L3')
SELECT rut,SUM(oc) AS oc, SUM(nlic) AS nlic FROM
(
SELECT t1.rut AS rut,COUNT(*) AS oc ,0 AS nlic FROM #temp AS t1
GROUP BY t1.rut
UNION
SELECT t2.rut AS rut,0 AS oc,COUNT(*) AS nlic FROM #temp2 AS t2
GROUP BY t2.rut
) AS t3 GROUP BY t3.rut