This problem is known as "Finding Islands", but this case is a special one because there is no other column that we could use to break ties based on (CID, cDate) other than column [Dept].
I added one more column, an identity one, to break this tie, and here is the code.
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE #tTable(
sk int NOT NULL IDENTITY UNIQUE CLUSTERED,
CID INT,
CDate DATETIME,
Dept VARCHAR(10)
);
INSERT INTO #tTable(CID, CDate, Dept)
VALUES
(111,'2012-10-05 00:00:00.000','A'),
(111,'2012-10-18 00:00:00.000','C'),
(111,'2012-11-01 00:00:00.000','B'),
(111,'2012-11-01 00:00:00.000','C'),
(111,'2012-11-20 00:00:00.000','C'),
(111,'2012-12-09 00:00:00.000','C'),
(111,'2012-12-11 00:00:00.000','A'),
(111,'2013-02-21 00:00:00.000','B'),
(111,'2013-03-22 00:00:00.000','B'),
(111, '2013-03-22 00:00:00.000','C'),
(111,'2013-04-12 00:00:00.000','C'),
(111,'2013-04-26 00:00:00.000','B'),
(111,'2013-04-26 00:00:00.000','C'),
(222,'2012-02-13 00:00:00.000','C'),
(222,'2012-03-02 00:00:00.000','B'),
(222, '2012-06-16 00:00:00.000','C'),
(222,'2012-07-12 00:00:00.000','C'),
(222,'2013-04-26 00:00:00.000','B'),
(222, '2013-05-23 00:00:00.000','C'),
(222,'2013-07-11 00:00:00.000','C'),
(222,'2013-09-19 00:00:00.000','C'),
(222,'2013-09-20 00:00:00.000','A'),
(444, '2013-01-14 00:00:00.000','C'),
(444,'2013-02-14 00:00:00.000','C'),
(444,'2013-03-14 00:00:00.000','B'),
(444,'2013-04-14 00:00:00.000','C'),
(444,'2013-05-14 00:00:00.000','C');
WITH C1 AS (
SELECT
CID,
CDate,
Dept,
DENSE_RANK() OVER(PARTITION BY CID ORDER BY CDate, sk) -
DENSE_RANK() OVER(PARTITION BY CID ORDER BY Dept, CDate, sk) AS grp
FROM
#tTable
)
, C2 AS (
SELECT
CID,
grp,
MIN(cDate) dt
FROM
C1
GROUP BY
CID, grp
HAVING
SUM(CASE WHEN Dept <> 'C' THEN 1 ELSE 0 END) = 0
AND COUNT(*) > 1
)
SELECT
A.CID,
A.cDate,
A.Dept,
DENSE_RANK() OVER(PARTITION BY B.CID ORDER BY B.dt) AS grpnum
FROM
C1 AS A
INNER JOIN
C2 AS B
ON B.CID = A.CID
AND B.grp = A.grp
ORDER BY
A.CID, A.CDate;
GO
DROP TABLE #tTable
GO
/*
Result
CIDcDateDeptgrpnum
1112012-11-01 00:00:00.000C1
1112012-11-20 00:00:00.000C1
1112012-12-09 00:00:00.000C1
1112013-03-22 00:00:00.000C2
1112013-04-12 00:00:00.000C2
2222012-06-16 00:00:00.000C1
2222012-07-12 00:00:00.000C1
2222013-05-23 00:00:00.000C2
2222013-07-11 00:00:00.000C2
2222013-09-19 00:00:00.000C2
4442013-01-14 00:00:00.000C1
4442013-02-14 00:00:00.000C1
4442013-04-14 00:00:00.000C2
4442013-05-14 00:00:00.000C2
*/
The idea is to enumerate rows based on two criteria that together will yield a group number. Then you need to solve a second problem known as Relational Division[/url].
You can learn more about solving this problem, in the last book from Itzik Ben-Gan about T-SQL Querying.