Сценарий SQL:
select can.Reference, can.CandidateID, can.firstname + ' ' + can.surname AS 'Candidate',
con.firstname + ' ' + con.lastname as 'Consultant', sector.unitname from candidate can
inner join address ad on can.address = ad.addressid
inner join consultants con on con.consultantid = can.owningconsultant
inner join client cl on cl.ownedby = con.consultantid
inner join clientdata cd on cd.clientid = cl.clientid
inner join businessunits sector on sector.unitid = cd.ClientSectorID
where can.division = 1
and
can.OwningConsultant = 385
and
can.status in ('56','179')
group by can.Reference, can.CandidateID, can.FirstName, can.Surname, con.FirstName, con.LastName, can.Created, sector.unitname
order by can.created desc
Набор результатов:
Ref CanID CanName ConName Sector
Bob1 188435 Eve Evil Charlie Chaplin Nursery
Bob1 188435 Eve Evil Charlie Chaplin Private Schools
Bob1 188435 Eve Evil Charlie Chaplin Secondary
Bob1 188435 Eve Evil Charlie Chaplin SEN
В приведенном выше примере вы можете видеть, что возвращаются 4 результата, где я хотел бы, если их больше, чемодин за это сказать:
Ref CanID CanName ConName Sector
Bob1 188435 Eve Evil Charlie Chaplin Nursery, Private Schools, Secondary, SEN
Как мне достичь вышеупомянутого?