Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL query to group and create custom column

$
0
0

Hi,

I use SQL server Management studio,

In Table1 we have Name and Dept column, if the person is in more than one dept then assign then as result shown below.

Is this possible to do it using case statement

Table1

Name Dept
A Finances
A Sales
B Finances
B Sales
B Billing
C Finances
D Sales

Result:

Name Dept Dept_Group
A Finances F/S
A Sales F/S
B Finances F/S/B
B Sales F/S/B
B Billing F/S/B
C Finances F
D Sales S

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>