SELECT c.VocationSubName,d.ChengQuName
,Sum(case when HappenTime between '2003-1-1' And '2003-3-1' then a.thisterm else 0 end) as ThisTerm,
        Sum(case when HappenTime between '2002-1-1' And '2002-3-1' then a.thisterm else 0 end) as LastTerm
FROM
QR_SellInfo a,
QR_UnitInfo b,
QR_VocationSubInfo c,
QR_ChengQuXian d
WHERE a.UnitId = b.UnitId
And c.VocationSubId = b.VocationSubId
And d.ChengQuId = '1'
GROUP BY c.VocationSubName,d.ChengQuName