ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.SQL query to combine duplicate rows with comma separated values in SQL Server<p>Dear @priyajsr,</p> <p>Please refer below query , you will get answer. make sure no other conditions.</p> <pre class="brush: sql">SELECT DISTINCT (SELECT distinct EnrollNumber FROM Log lg4 WHERE Log.EnrollNumber=lg4.EnrollNumber AND lg4.InputMode=Log.InputMode AND CONVERT(date,lg4.Date)=CONVERT(date,Log.Date)) as EnrollNumber, (SELECT min(CONVERT(VARCHAR(10), Date, 121)) FROM Log lg1 WHERE Log.EnrollNumber=lg1.EnrollNumber AND lg1.InputMode=Log.InputMode AND CONVERT(date,lg1.Date)=CONVERT(date,Log.Date)) as Date, (SELECT STUFF((SELECT &#39;,&#39;+ CONVERT(VARCHAR(8), lg2.Date,114) FROM Log lg2 WHERE lg2.EnrollNumber = Log.EnrollNumber AND InputMode=0 AND CONVERT(date,lg2.Date)=CONVERT(date,Log.Date) FOR XML PATH(&#39;&#39;)),1,1,&#39;&#39;)) as InTime, (SELECT STUFF((SELECT &#39;,&#39;+ CONVERT(VARCHAR(8), lg3.Date,114) FROM Log lg3 WHERE lg3.EnrollNumber = Log.EnrollNumber AND InputMode=1 AND CONVERT(date,lg3.Date)=CONVERT(date,Log.Date) FOR XML PATH(&#39;&#39;)),1,1,&#39;&#39;)) as OutTime FROM Log where EnrollNumber=&#39;7024&#39; order by [Date]</pre>https://www.aspforums.net:443/Threads/355296/SQL-query-to-combine-duplicate-rows-with-comma-separated-values-in-SQL-Server/https://www.aspforums.net:443/Threads/355296/SQL-query-to-combine-duplicate-rows-with-comma-separated-values-in-SQL-Server/Tue, 12 Jun 2018 00:59:42 GMT