SELECT c1,c2,(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c3) AS c3,
(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c4) AS c4,
(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c5) AS c5
FROM T2
SELECT c1,c2,(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c3 ORDER BY T1.c12 DESC) AS c3,
(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c4 ORDER BY T1.c12) AS c4,
(SELECT TOP 1 c12 FROM T1 WHERE T1.c10=T2.c5 ORDER BY T1.c10) AS c5
FROM T2