0
S.No  Name  Path
1     a      a/b/c
2     b      x/y/z
3     a      a/b/c
4     c       t/y/z
5     b      x/y/z

in my sql to find repeated values

select Name,Path,Count(Name), group_concat(S.No) as Concatlist from tab 
group by Name, Path
OutPut will be 
a   a/b/c   2     1,3
b   x/y/z   2     2,5

c    t/y/z  1     4

Same query i want in ms sql server..

Please notice concatlist S.No column not using in group by....

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Does this answer your question? [How to use GROUP BY to concatenate strings in SQL Server?](https://stackoverflow.com/questions/273238/how-to-use-group-by-to-concatenate-strings-in-sql-server) – Charlieface Apr 01 '21 at 17:35

1 Answers1

0

You can use string_agg() in the more recent versions of SQL Server:

select name, path, count(*),
       string_agg(s_no order by s_no) as s_nos
from t
group by name, path;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786