Combine two columns in SQL Server: one column has varchar values and other column has int values.
.
This is the code I have used to get the result
Trying to combine two columns: one column is varchar and another one is int.
I'm trying to combine learningareas and Noramlyearlevel columns.
This is the actual query.
select distinct v.StaffPreferredName, v.StaffSurname, v.StaffOccupEmail,
l.learningareacode as 'Learning Areas',
sc.NormalYearLevel as 'NormalYearLevel'
from vstaffDescription'
And I'm trying to get the result output like this
.
I tried this code,
I got the output as,
Alexander Scott Alex.Scott@pegs.vic.edu.au Geography: 8, Geography: 8, Geography: 8, Politics: 10, Politics: 10.
Please guide me to get the required output.
Thanks
2条答案
按热度按时间wfauudbj1#
Please avoid images when forming questions - and also do include the complete query you have tried (it seems you omitted some parts). In essence what you want to do is remove the unwanted repetition of data before you use string_agg e.g:
You will need to repair the missing table references and joins.
t2a7ltrp2#