Can someone tell me what these two case statements are doing please.
SELECT c.officecode AS doc,
CASE
WHEN typecode IN ( 1, 18 ) THEN reportsto
WHEN typecode IN ( 13 ) THEN officecode
ELSE NULL
END AS dist,
c.region AS reg, r.regionacronym,
CASE
WHEN area < 10 THEN '0' + CAST(area AS CHAR(1))
ELSE CAST(area AS CHAR(2))
END AS area,
REPLACE(c.name, ',', '') AS doc_name,
r.regionnumber AS region_num, r.regionname,
c.typecode
FROM offices.dbo.officecodes AS c
INNER JOIN offices.dbo.regions AS r
ON c.region = r.regionletter
WHERE ( c.typecode IN ( 1, 18, 13 ) )
SELECT c.officecode AS doc,
CASE
WHEN typecode IN ( 1, 18 ) THEN reportsto
WHEN typecode IN ( 13 ) THEN officecode
ELSE NULL
END AS dist,
c.region AS reg, r.regionacronym,
CASE
WHEN area < 10 THEN '0' + CAST(area AS CHAR(1))
ELSE CAST(area AS CHAR(2))
END AS area,
REPLACE(c.name, ',', '') AS doc_name,
r.regionnumber AS region_num, r.regionname,
c.typecode
FROM offices.dbo.officecodes AS c
INNER JOIN offices.dbo.regions AS r
ON c.region = r.regionletter
WHERE ( c.typecode IN ( 1, 18, 13 ) )