日期:2014-05-17 浏览次数:20766 次
SELECT a.ID, (CASE e.Name WHEN 'AA' THEN CAST(b.czwt AS varchar) ELSE 'X' END) AS 'AA',
(CASE e.Name WHEN 'BB' THEN CAST(b.czwt AS varchar) ELSE 'X' END) AS 'BB',
(CASE e.Name WHEN 'CC' THEN CAST(b.czwt AS varchar) ELSE 'X' END) AS 'CC'
FROM a INNER JOIN
b ON a.ID = b.XX_ID INNER JOIN
c ON b.hfz = c.ID INNER JOIN
e ON c.CJ = e.ID
GROUP BY a.ID
order by e.Name,b.czwt