<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Schedules &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/schedules/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 14 Aug 2017 21:30:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Puzzle: SQL Advance Query &#8211; Create comma separated aggregation for Common schedules</title>
		<link>https://www.dbrnd.com/2017/08/sql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules/</link>
					<comments>https://www.dbrnd.com/2017/08/sql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 23 Aug 2017 16:16:34 +0000</pubDate>
				<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Schedules]]></category>
		<category><![CDATA[SQL Advance Query]]></category>
		<category><![CDATA[SQL Interview]]></category>
		<category><![CDATA[SQL Problem]]></category>
		<category><![CDATA[SQL Programming]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5958</guid>

					<description><![CDATA[Check the below input data and expected output to make the comma separated week aggregation for common schedules. Input Data: [crayon-6ab55d6a9ae76372984773/] Expected Output: [crayon-6ab55d6a9ae79426134139/] Create a table with sample data: [crayon-6ab55d6a9ae7a788786593/] Solution: [crayon-6ab55d6a9ae7b641652782/] Please try the different solution for this puzzle and share it via comment...]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules%2F&#038;title=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Create%20comma%20separated%20aggregation%20for%20Common%20schedules" data-a2a-url="https://www.dbrnd.com/2017/08/sql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules/" data-a2a-title="SQL Puzzle: SQL Advance Query – Create comma separated aggregation for Common schedules"></a></p><p>Check the below input data and expected output to make the comma separated week aggregation for common schedules. </p>
<p><strong>Input Data:</strong></p>
<pre class="crayon-plain-tag">ScheduleID  StartDate  EndDate    WeekID
----------- ---------- ---------- ------
1           2017-01-08 2017-01-09 1
1           2017-01-08 2017-01-09 2
2           2017-02-08 2017-02-09 4
3           2017-04-08 2017-05-08 6
3           2017-04-08 2017-05-08 7
4           2017-02-10 2017-04-09 3</pre> </p>
<p><strong>Expected Output:</strong></p>
<pre class="crayon-plain-tag">ScheduleID  StartDate  EndDate    Weeks
----------- ---------- ---------- -------
4           2017-02-10 2017-04-09  3
3           2017-04-08 2017-05-08  6, 7
2           2017-02-08 2017-02-09  4
1           2017-01-08 2017-01-09  1, 2</pre> </p>
<p><strong>Create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE Schedules  
(
	ScheduleID INT 
	,StartDate DATE
	,EndDate DATE
	,WeekID VARCHAR(2)	
) 
GO
 
INSERT INTO Schedules 
VALUES
(1,'2017-01-08','2017-01-09',1)
,(1,'2017-01-08','2017-01-09',2)
,(2,'2017-02-08','2017-02-09',4)
,(3,'2017-04-08','2017-05-08',6)
,(3,'2017-04-08','2017-05-08',7)
,(4,'2017-02-10','2017-04-09',3)
GO</pre> </p>
<p><strong>Solution:</strong></p>
<pre class="crayon-plain-tag">SELECT ScheduleID,StartDate, EndDate,
STUFF(( SELECT ', ' + t1.WeekID 
FROM Schedules  t1 
WHERE s.ScheduleID = t1.ScheduleID 
        AND s.StartDate = t1.StartDate 
        AND s.EndDate = t1.EndDate         
        FOR XML PATH('')), 1, 1, '') Weeks
FROM Schedules s
GROUP BY ScheduleID,StartDate,EndDate
ORDER BY ScheduleID DESC</pre> </p>
<p><strong><code>Please try the different solution for this puzzle and share it via comment...</code></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/08/sql-puzzle-sql-advance-query-create-comma-separated-aggregation-for-common-schedules/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
