This is essentially and gaps & islands type of issue - and you can use several different methods for identify them. Using LEAD/LAG would be one of the simpler methods in my opinion.
Since you have a calculation for the 4th column - it gets a bit tricky to structure...something like this:
With dailyDemand
As (
Select b.ID
, b.[Clino]
, [Past/Future]
, [Specialty_Clinic]
, [Conscode_Clinic]
, [Consultant_Clinic]
, [Locspec_Clinic]
, [ClinLoc]
, [ClinDate]
, convert(datetime, [clindate], 112) As 'Date'
, datepart(WK, convert(datetime, [clindate] , 112)) As 'Week'
, datename(dw, convert(datetime, [clindate] , 112)) As 'Day'
, b.[ApTime]
, iif(b.[aptime] > '1259' , 'Afternoon' , 'Morning') As 'Session Type'
, c.[Attime]
, c.[Seentime]
, [Duration]
, [Slot]
, [Booked]
, [Empty]
, b.[Unitno]
, [ReasonableOffer]
, [ForceBookOnly]
, [OvbkSlot]
, [Bkdover]
, [CBSlot]
, [CBBkd]
, b.[Refsrce]
, [Attendance]
, c.Walkin
, [Cancelled]
, [VisitType]
, b.schdl_refno
, a.speccode
, a.division
, c.attended_dna_cds
, c.First_Attendance
, iif(c.[first_attendance] = '1', 'New', iif(c.[first_attendance] = '2', 'Follow Up'
, iif(c.[First_attendance] = '3', 'Telephone', iif(c.[first_attendance] = '4' , 'Telephone' , 'Empty')))) As Type
, [Booked] * [duration] As APPOINTMENTTIME
From [daily_builds].[dbo].[Daily_Demand_and_Capacity] b
Left Join information.dbo.specialty a On b.Locspec_clinic = a.speccode
Left Join [final].dbo.final_op C On b.schdl_refno = c.Schdl_Refno
Where (a.Division = 'B')
And ([clindate] >= '20160301' And [clindate] <= '20170228')
)
Select *
, iif(d.[Session Type] <> lag(d.[Session Type], 1, 1) over(Partition By d.Name, d.Type, d.Date Order By d.ApTime), 1, 0) As Match
From dailyDemand d
Replace the partition columns with the appropriate columns from your actual query and you should get the desired result. I cannot test without actual data to validate...
I moved your query into a CTE so I could reference the computed columns without having to repeat the calculation - which simplifies the LAG function so I can insure the LAG returns a 1 when there isn't a previous row.