<?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>Uncategorized &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/category/uncategorized/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>Fri, 06 Oct 2017 18:58:32 +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; Find maximum consecutive wins for team India</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india/</link>
					<comments>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 18 Oct 2017 16:16:09 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Puzzle]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5823</guid>

					<description><![CDATA[Check the below input data and require output data to find maximum consecutive wins for team India. Input Data: [crayon-6ab6c78d03365107344619/] Expected output: [crayon-6ab6c78d03368038176204/] Create a table with sample data: [crayon-6ab6c78d03369815674319/] Solution: [crayon-6ab6c78d0336a223885719/] Please try the different solutions 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" 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%2F10%2Fsql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india%2F&#038;title=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Find%20maximum%20consecutive%20wins%20for%20team%20India" data-a2a-url="https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india/" data-a2a-title="SQL Puzzle: SQL Advance Query – Find maximum consecutive wins for team India"></a></p><p>Check the below input data and require output data to find maximum consecutive wins for team India.</p>
<p><strong>Input Data:</strong></p>
<pre class="crayon-plain-tag">TeamOne TeamTwo MatchDate  WonBy
------- ------- ---------- -----
Ind     Aus     2017-08-22 Ind
Ind     Aus     2016-08-26 Ind
Ind     Aus     2014-08-14 Ind
Ind     Aus     2013-08-23 Aus
Ind     Aus     2012-08-25 Ind
Ind     Aus     2010-08-08 Ind</pre> </p>
<p><strong>Expected output:</strong></p>
<pre class="crayon-plain-tag">TeamOne TeamTwo MatchDate  WonBy
------- ------- ---------- -----
Ind     Aus     2014-08-14 Ind
Ind     Aus     2012-08-25 Ind
Ind     Aus     2010-08-08 Ind</pre> </p>
<p><strong>Create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE Matches
(
	TeamOne CHAR(3)
	,TeamTwo CHAR(3)
	,MatchDate DATE
	,WonBy CHAR(3)
)
GO
 
INSERT INTO Matches
VALUES
('Ind','Aus','08-22-2017','Ind')
,('Ind','Aus','08-26-2016','Ind')
,('Ind','Aus','08-14-2014','Ind')
,('Ind','Aus','08-23-2013','Aus')
,('Ind','Aus','08-25-2012','Ind')
,('Ind','Aus','08-08-2010','Ind')
GO</pre> </p>
<p><strong>Solution:</strong></p>
<pre class="crayon-plain-tag">;WITH CTE AS
(
	SELECT TeamOne,TeamTwo,MatchDate,WonBy         
	,ISNULL(Lead(WonBy) OVER (ORDER BY (SELECT NULL)),0) AS NextWin
	FROM Matches
)
,CTE2 AS
(
	SELECT *,IIF(NextWin&lt;&gt; WonBy,1,0) AS a
	,ROW_NUMBER() OVER( ORDER BY (SELECT NULL)) AS b
	FROM cte
)
,CTE3 AS
(
    SELECT *, b - ISNULL(lag(b) OVER (ORDER BY (SELECT NULL)),0) AS C 
	FROM CTE2
    WHERE a = 1
)
SELECT t2.* FROM cte3 t1
RIGHT OUTER JOIN Matches t2 ON t1.MatchDate = t2.MatchDate
WHERE t2.MatchDate  &lt;= (SELECT MatchDate FROM cte3 WHERE C = (SELECT MAX(C) FROM CTE3))
AND t2.WonBy = (SELECT WonBy FROM cte3 WHERE C = (SELECT MAX(C) FROM CTE3))</pre> </p>
<p><strong><code>Please try the different solutions for this puzzle and share it via comment...</code></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-maximum-consecutive-wins-for-team-india/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Greenplum: How to check the Database Schema Size?</title>
		<link>https://www.dbrnd.com/2017/06/greenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 29 Jun 2017 16:16:21 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_size_of_schema_disk]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[pg_namespace]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[size]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5441</guid>

					<description><![CDATA[Greenplum is a based on MVCC architecture that means user&#8217;s action like UPDATE will insert a new record in a database. Greenplum Data warehouse can manage billions of data, but it doesn&#8217;t mean that user can generate or UPDATE random data set. Periodically, The Greenplum DBA should check the size of database schemas and their [&#8230;]]]></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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&amp;linkname=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" 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%2F06%2Fgreenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk%2F&#038;title=Greenplum%3A%20How%20to%20check%20the%20Database%20Schema%20Size%3F" data-a2a-url="https://www.dbrnd.com/2017/06/greenplum-how-to-check-the-database-schema-size-gp_toolkit-gp_size_of_schema_disk/" data-a2a-title="Greenplum: How to check the Database Schema Size?"></a></p><p>Greenplum is a based on MVCC architecture that means user&#8217;s action like UPDATE will insert a new record in a database.<br />
Greenplum Data warehouse can manage billions of data, but it doesn&#8217;t mean that user can generate or UPDATE random data set.<br />
Periodically, The Greenplum DBA should check the size of database schemas and their appropriate usage.</p>
<p>In this post, I shared different scripts to check the size of Greenplum Database Schemas.</p>
<p><strong>Option 1:</strong></p>
<pre class="crayon-plain-tag">select *
from gp_toolkit.gp_size_of_schema_disk;</pre> </p>
<p><strong>Option 2:</strong></p>
<pre class="crayon-plain-tag">select
	schemaname
	,round(sum(pg_total_relation_size(schemaname||'.'||tablename))) SchemaSize
from pg_tables group by 1;</pre> </p>
<p><strong>Option 3:</strong></p>
<pre class="crayon-plain-tag">SELECT
	schema_name
	,pg_size_pretty(sum(table_size)::bigint)
FROM
(
	SELECT pg_catalog.pg_namespace.nspname as schema_name,
	pg_relation_size(pg_catalog.pg_class.oid) as table_size
	FROM pg_catalog.pg_class
	JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid
) t
GROUP BY schema_name
ORDER BY schema_name;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
