<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Malik M</title>
    <description>The latest articles on DEV Community by Malik M (@mmmalik45).</description>
    <link>https://dev.to/mmmalik45</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1128448%2Ff50891ad-3ebe-4351-b93a-10aac9e0d9ba.png</url>
      <title>DEV Community: Malik M</title>
      <link>https://dev.to/mmmalik45</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mmmalik45"/>
    <language>en</language>
    <item>
      <title>Webinar</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Thu, 14 Sep 2023 15:33:38 +0000</pubDate>
      <link>https://dev.to/mmmalik45/webinar-45i4</link>
      <guid>https://dev.to/mmmalik45/webinar-45i4</guid>
      <description>&lt;p&gt;Ever wondered how #PostgreSQL can be combined with graph technologies can shape enterprise data management solutions?&lt;br&gt;
Join the webinar : &lt;br&gt;
Registration link: &lt;a href="https://us06web.zoom.us/webinar/register/WN_PohMAFj0RJuJPAw8bTq1MA#/registration"&gt;https://us06web.zoom.us/webinar/register/WN_PohMAFj0RJuJPAw8bTq1MA#/registration&lt;/a&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>graphql</category>
    </item>
    <item>
      <title>GROUP BY clause in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Thu, 17 Aug 2023 21:09:17 +0000</pubDate>
      <link>https://dev.to/mmmalik45/group-by-clause-in-postgresql-221f</link>
      <guid>https://dev.to/mmmalik45/group-by-clause-in-postgresql-221f</guid>
      <description>&lt;p&gt;In this tutorial we will learn about the use of &lt;code&gt;GROUP BY&lt;/code&gt; clause.&lt;br&gt;
So, let's get started...&lt;br&gt;
It is used to divide the rows in groups that are return from the &lt;code&gt;SELECT&lt;/code&gt; statement. You can then apply aggregate functions such as 'SUM()' or 'COUNT()' to each group to find sum or number of items in the groups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
   column_1, 
   column_2,
   ...,
   aggregate_function(column_3)
FROM 
   table_name
GROUP BY 
   column_1,
   column_2,
   ...;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above statement shows the syntax of the 'GROUP BY' clause.&lt;br&gt;
In this syntax, first select the columns that you want to group and apply the aggregate function such as here we can see I have used 'column_1', 'column_2' in the above syntax.&lt;br&gt;
Second list all the columns in the 'GROUP BY' that you want to group.&lt;/p&gt;

&lt;p&gt;PostgreSQL evaluates the 'GROUP BY' after the 'FROM' and 'WHERE' clauses but it is evaluated before 'HAVING', 'SELECT', 'DISTINCT', 'ORDER BY' and 'LIMIT' clauses.&lt;br&gt;
This can be seen through the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QL-vCX6S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o21dfyxd166ytsedrukc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QL-vCX6S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o21dfyxd166ytsedrukc.png" alt="Image description" width="185" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1) GROUP BY without an aggregate function:&lt;/strong&gt;&lt;br&gt;
We can also use the 'GROUP BY' without using any aggregate function. Let's see an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
   customer_id
FROM
   payment
GROUP BY
   customer_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code it gets the data from the 'payment' table and group them by the customer id. Here it acts like distinct and removes all the duplicate results from the set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m5ezTeTV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5sgl74mquo5pbzghmig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m5ezTeTV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5sgl74mquo5pbzghmig.png" alt="Image description" width="213" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) GROUP BY with SUM() function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
    customer_id,
    SUM (amount)
FROM
    payment
GROUP BY
    customer_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To calculate and select the total amount each customer has paid, we can use the 'GROUP BY' clause to first divide the rows in groups in the 'payment' table and then for each group sum the total amount.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dgvrokm---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3c07ssmmefxwiqvzo0ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dgvrokm---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3c07ssmmefxwiqvzo0ve.png" alt="Image description" width="252" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
In this article we learned about 'GROUP BY' clause.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>postgressql</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>UPDATE statement in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Thu, 17 Aug 2023 20:28:14 +0000</pubDate>
      <link>https://dev.to/mmmalik45/update-statement-in-postgresql-5ed2</link>
      <guid>https://dev.to/mmmalik45/update-statement-in-postgresql-5ed2</guid>
      <description>&lt;p&gt;In this tutorial, We will be exploring how to update the data in an existing table.&lt;br&gt;
Let's get started...&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;UPDATE&lt;/code&gt; statement is used to modify the data in an existing table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE table_name
SET column1 = value1,
    column2 = value2,
    ...
WHERE condition;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above syntax, we can see that first we have specify the table name with the &lt;code&gt;UPDATE&lt;/code&gt; keyword.&lt;br&gt;
Second, we have to specify the columns that we want to update and their updated values after 'SET' keyword. Also note that those columns that do not appear in the 'SET' clause won't be modified. &lt;br&gt;
Third, we have to write the conditions which rows to be updated in the table after the 'WHERE' clause.&lt;/p&gt;

&lt;p&gt;If you want to return the row that is/are just modified use the following code in the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RETURNING *;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;EXAMPLE&lt;/strong&gt;&lt;br&gt;
Let's look at the example and practice it.&lt;br&gt;
Suppose we have the following table which shows all the courses and description:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5WypHdoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdgs1sby4l2ykc3cdwq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5WypHdoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdgs1sby4l2ykc3cdwq4.png" alt="Image description" width="696" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) Update one row from table&lt;/strong&gt;&lt;br&gt;
The following query will modify one row from the table  that has &lt;code&gt;id&lt;/code&gt;=2 and sets it &lt;code&gt;published_date&lt;/code&gt; to &lt;code&gt;2020-07-01&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE courses
SET published_date = '2020-07-01'
WHERE course_id = 2
RETURNING *;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iPxaHjmw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gryohwepgxik0mxi594e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iPxaHjmw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gryohwepgxik0mxi594e.png" alt="Image description" width="582" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article we learnt about the 'UPDATE' statement and it's example.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>postgressql</category>
      <category>programming</category>
      <category>database</category>
    </item>
    <item>
      <title>PostgreSQL - History and Common Use cases</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Thu, 17 Aug 2023 19:07:11 +0000</pubDate>
      <link>https://dev.to/mmmalik45/postgresql-history-and-common-use-cases-44kc</link>
      <guid>https://dev.to/mmmalik45/postgresql-history-and-common-use-cases-44kc</guid>
      <description>&lt;p&gt;In this article I will tell you about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is PostgreSQL? &lt;/li&gt;
&lt;li&gt;History of PostgreSQL?&lt;/li&gt;
&lt;li&gt;Common use cases of PostgreSQL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So let's get started with first question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is PostgreSQL?&lt;/strong&gt;&lt;br&gt;
PostgreSQL is an advanced open-source relational database system that supports both relational (SQL) and non-relational (JSON) queries. It is one of the highly stable database as it was build more than 20 years ago and it is backed by the open-source community. &lt;br&gt;
It is used as a primary database not just for the web applications but also mobile and analytics applications too.&lt;/p&gt;

&lt;p&gt;So this was a little introduction of the PostgreSQL.&lt;br&gt;
Now let's look at the history of PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;History&lt;/strong&gt; &lt;br&gt;
PostgreSQL originally named as POSTGRES was started in 1986 at Berkeley Computer Science Department, University of California.&lt;br&gt;
The name POSTGRES was in reference to the Ingres that is also a database developed in Berkeley. POSTGRES main goal was to add features needed to support multiple datatypes.&lt;br&gt;
It was renamed to PostgreSQL in 1996 to show it's support for the SQL.&lt;br&gt;
Did you know that it was originally designed to run on UNIX-like programs only. But as the time passed, it was evolved to run on various platforms like macOS, Windows and Solaris.&lt;/p&gt;

&lt;p&gt;Now let's dive into some of the use cases of the PostgreSQL also known as Postgres.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common use cases&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Robust database:&lt;br&gt;
It is used as primary back-end database because of it's robustness to power dynamic websites and web applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;General purpose:&lt;br&gt;
It is used in large number of organizations and startups to support their real life  products and applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Geospatial database: &lt;br&gt;
It can help in storing, indexing and querying the geographical data with the PostGIS extensions for the geographic information system.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Languages it support&lt;/strong&gt;&lt;br&gt;
It supports almost all the popular languages such as Python, Java, JavaScript, C/C++, Ruby, Go, Perl and Tcl.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>postgressql</category>
      <category>database</category>
      <category>programming</category>
    </item>
    <item>
      <title>INSERT statement in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Thu, 17 Aug 2023 18:34:45 +0000</pubDate>
      <link>https://dev.to/mmmalik45/insert-statement-in-postgresql-n83</link>
      <guid>https://dev.to/mmmalik45/insert-statement-in-postgresql-n83</guid>
      <description>&lt;p&gt;In this tutorial, We will be exploring how to add new row in the existing table.&lt;br&gt;
Let's get started...&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;INSERT&lt;/code&gt; statement is used to insert a new row in the table. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO table_name(column1, column2, …)
VALUES (value1, value2, …);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above syntax, we can see that first we have specify the table name with the &lt;code&gt;INSERT INTO&lt;/code&gt; keywords and the table will have list of comma-separated columns in the brackets.&lt;br&gt;
Second, we have to provide values against each column after &lt;code&gt;VALUES&lt;/code&gt; keyword, that must be in the same orders as columns are.&lt;br&gt;
If you want to return the row that is just inserted use the following code in the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RETURNING *;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to return just some information, just specify the one or more column names after 'RETURNING' keyword like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RETURNING id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code I am returning ID only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXAMPLE&lt;/strong&gt;&lt;br&gt;
Getting the last insert 'id':&lt;br&gt;
Suppose we want to return the id of the last in the table Named &lt;code&gt;links&lt;/code&gt; that has &lt;code&gt;url&lt;/code&gt; and the &lt;code&gt;name&lt;/code&gt;, 'id' and 'description' as columns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO links (url, name)
VALUES('http://www.postgresql.org','PostgreSQL') 
RETURNING id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code we are inserting 'url' and 'name' values and returning the &lt;code&gt;id&lt;/code&gt; of the last insert.&lt;br&gt;
&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rrGzocF6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31r23tncpv6otymk1b6a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rrGzocF6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31r23tncpv6otymk1b6a.png" alt="Image description" width="150" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article we learnt about the 'INSERT' statement and it's example.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DELETE statement in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Tue, 15 Aug 2023 18:53:30 +0000</pubDate>
      <link>https://dev.to/mmmalik45/delete-statement-in-postgresql-3nec</link>
      <guid>https://dev.to/mmmalik45/delete-statement-in-postgresql-3nec</guid>
      <description>&lt;p&gt;In this tutorial we will learn about the use of &lt;code&gt;DELETE&lt;/code&gt; statement.&lt;br&gt;
So, let's get started...&lt;br&gt;
&lt;strong&gt;Use of &lt;code&gt;DELETE&lt;/code&gt; statement&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;DELETE&lt;/code&gt; statement is used to delete one or more rows from a table.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM table_name
WHERE condition;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above syntax first we need to specify the table from which we want to delete the rows. &lt;br&gt;
Second we have to specify the condition in the &lt;code&gt;WHERE&lt;/code&gt; clause to delete the rows.&lt;br&gt;
Note one thing here, 'WHERE' clause is optional, if we omit the 'WHERE' clause, it will delete all the rows in the table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Let's look at the example and practice it.&lt;br&gt;
Suppose we have the following table which shows all the links to websites:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zgoDt9PF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj25yipdd3yjx7w4qop2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zgoDt9PF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj25yipdd3yjx7w4qop2.png" alt="Image description" width="779" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) DELETE one row from table&lt;/strong&gt;&lt;br&gt;
The following query will delete one row from the table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM links
WHERE id = 8;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query deletes the row which has &lt;code&gt;id&lt;/code&gt;=8. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) Delete a row and return the deleted row&lt;/strong&gt;&lt;br&gt;
In this example we will see how to return a deleted row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM links
WHERE id = 7
RETURNING *;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above syntax row which has &lt;code&gt;id&lt;/code&gt;=7 is deleted. The &lt;code&gt;RETURNING&lt;/code&gt; statement at the end returns the deleted row.&lt;br&gt;
Output is as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8uiBCiAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ih8tvli2o1iet5p3181v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8uiBCiAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ih8tvli2o1iet5p3181v.png" alt="Image description" width="779" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this tutorial we explored about the 'DELETE' statement in PostgreSQL.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>EXISTS in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Tue, 15 Aug 2023 18:35:18 +0000</pubDate>
      <link>https://dev.to/mmmalik45/exists-in-postgresql-3j5j</link>
      <guid>https://dev.to/mmmalik45/exists-in-postgresql-3j5j</guid>
      <description>&lt;p&gt;In this tutorial, I will be explaining how can we use the &lt;code&gt;EXISTS&lt;/code&gt; in a subquery.&lt;br&gt;
Let's get started...&lt;br&gt;
&lt;code&gt;EXISTS&lt;/code&gt; is a boolean operator, and it tests for the existence of rows in a subquery.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
Following is the syntax of using &lt;code&gt;EXISTS&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXISTS (subquery)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;EXISTS&lt;/code&gt; operator accepts a subquery as an argument.&lt;br&gt;
Result of &lt;code&gt;EXISTS&lt;/code&gt; is true if the subquery returns at least one row.&lt;br&gt;
Result of &lt;code&gt;EXISTS&lt;/code&gt; is false if the subquery returns no row.&lt;/p&gt;

&lt;p&gt;Let's see an example:&lt;br&gt;
For example we have following &lt;code&gt;customer&lt;/code&gt; and &lt;code&gt;payment&lt;/code&gt; tables in the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nm-alCkN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muh68dp54tvsu57lbh94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nm-alCkN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muh68dp54tvsu57lbh94.png" alt="Image description" width="561" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) Find customers whose at least one payment is greater than 11&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT first_name,
       last_name
FROM customer c
WHERE EXISTS
    (SELECT 1
     FROM payment p
     WHERE p.customer_id = c.customer_id
       AND amount &amp;gt; 11 )
ORDER BY first_name,
         last_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this, subquery checks &lt;code&gt;payment&lt;/code&gt; table for each customer and find that if there is any customer that has at least one payment that has amount greater than 11.&lt;br&gt;
The above query returns the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WD7np6dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5kuptk2o4tlgi3p2vrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WD7np6dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5kuptk2o4tlgi3p2vrn.png" alt="Image description" width="231" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) NOT EXISTS&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;NOT EXIST&lt;/code&gt; is opposite to &lt;code&gt;EXISTS&lt;/code&gt; operator, that means the result of &lt;code&gt;NOT EXISTS&lt;/code&gt; is true if the subquery returns no row and vice versa.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT first_name,
       last_name
FROM customer c
WHERE NOT EXISTS
    (SELECT 1
     FROM payment p
     WHERE p.customer_id = c.customer_id
       AND amount &amp;gt; 11 )
ORDER BY first_name,
         last_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above subquery checks &lt;code&gt;payment&lt;/code&gt; table for each customer and find that if there is any customer that has not made any payment amount greater than 11. &lt;/p&gt;

&lt;p&gt;The output of the query is as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YIQAtrM2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dlje2folttn2uk2vt2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YIQAtrM2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dlje2folttn2uk2vt2e.png" alt="Image description" width="251" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this tutorial we explored the basic level use of &lt;code&gt;EXISTS&lt;/code&gt; operator.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Finding COUNT, SUM, and AVG in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Sun, 30 Jul 2023 20:43:44 +0000</pubDate>
      <link>https://dev.to/mmmalik45/finding-count-sum-and-avg-in-postgresql-1lg1</link>
      <guid>https://dev.to/mmmalik45/finding-count-sum-and-avg-in-postgresql-1lg1</guid>
      <description>&lt;p&gt;In this tutorial, I will be explaining how can we find the count, sum and average in PostgreSQL query.&lt;br&gt;
Let's get started...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding Count of rows&lt;/strong&gt;&lt;br&gt;
In this section we will explore how can we find the count of rows.&lt;br&gt;
The COUNT() function returns the number of rows that matches a specified criteria.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(column_name)
FROM table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand by an example:&lt;br&gt;
Suppose we want to find the number of customers from the London in our &lt;code&gt;Customer&lt;/code&gt; table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(customer_id)
FROM customers
WHERE city = 'London';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query first find the rows which satisfies the &lt;code&gt;WHERE&lt;/code&gt; clause condition. Then counts the total number of rows and returns a number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m9hKnF6W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od1piena8iffq5ff35xl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m9hKnF6W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od1piena8iffq5ff35xl.png" alt="Image description" width="277" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding SUM&lt;/strong&gt;&lt;br&gt;
In this section we will explore how can we use SUM() function.&lt;br&gt;
The SUM() function returns the total sum of a numeric column.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(column_name)
FROM table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand by an example:&lt;br&gt;
Suppose we want to find the  the sum of the &lt;code&gt;quantity&lt;/code&gt; fields in the &lt;code&gt;order_details&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(quantity)
FROM order_details;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query returns the total number of items which are in ordered table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e0Sv4fNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zft3hc0i9jjitg6y42e9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e0Sv4fNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zft3hc0i9jjitg6y42e9.png" alt="Image description" width="261" height="72"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding AVG&lt;/strong&gt;&lt;br&gt;
In this section we will explore how can we use AVG() function.&lt;br&gt;
The AVG() function returns the average value of a numeric column.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT AVG(column_name)
FROM table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand by an example:&lt;br&gt;
Suppose we want to find the  the average price of all the products in the &lt;code&gt;product&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT AVG(price)
FROM products;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query returns the average price of all the products&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kg_4tF81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpl1iuq4eu6svpb8sm4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kg_4tF81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpl1iuq4eu6svpb8sm4o.png" alt="Image description" width="214" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this table we learnt about how we can use &lt;code&gt;Count&lt;/code&gt;, &lt;code&gt;SUM&lt;/code&gt; and &lt;code&gt;AVG&lt;/code&gt; in a query.&lt;/p&gt;

</description>
      <category>postgressql</category>
      <category>tutorial</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>Column Alias in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Sun, 30 Jul 2023 19:55:07 +0000</pubDate>
      <link>https://dev.to/mmmalik45/column-alias-in-postgresql-304p</link>
      <guid>https://dev.to/mmmalik45/column-alias-in-postgresql-304p</guid>
      <description>&lt;p&gt;In this article I will share how we can assign a column alias and it's in the PostgreSQL.&lt;br&gt;
Let's get started...&lt;br&gt;
Column alias is used to assign a temporary name to a column or an expression in the PostgreSQL. It exists only temporarily during the execution of query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of using a Column Alias&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT column_name AS alias_name
FROM table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As from the syntax, it can be seen that &lt;code&gt;column_name&lt;/code&gt; is assigned an alias &lt;code&gt;alias_name&lt;/code&gt;. Here &lt;code&gt;AS&lt;/code&gt; key is used to assign   the alias name. &lt;code&gt;AS&lt;/code&gt; key is optional to use. We can omit it as well. The syntax will be then as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT column_name alias_name
FROM table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Suppose we have the &lt;code&gt;customer&lt;/code&gt; table with following attributes in the database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O5RwQ_dt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ycaiao4yb8htq0ld6pj.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O5RwQ_dt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ycaiao4yb8htq0ld6pj.PNG" alt="Image description" width="243" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Assigning a column alias to a column:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
   first_name, 
   last_name AS surname
FROM customer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query assigned the &lt;code&gt;surname&lt;/code&gt; as column alias to the &lt;code&gt;last_name&lt;/code&gt;. If we have not used column alias then the name of the column would have appeared as "last_name".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DHpROnY0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igtibf8flpdahtgkq04g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DHpROnY0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igtibf8flpdahtgkq04g.png" alt="Image description" width="367" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Assigning a column alias to an expression:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
   first_name || ' ' || last_name AS full_name 
FROM 
   customer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query returns full names of all the customers. The expression &lt;code&gt;first_name || ' ' || last_name AS full_name&lt;/code&gt; constructs the full name by concatenating the first name, space and the last name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xj9iubDF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6ml037uak6me0r1m8fi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xj9iubDF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6ml037uak6me0r1m8fi.png" alt="Image description" width="220" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this tutorial we learnt about how we can assign temporary names to the queries using &lt;code&gt;AS&lt;/code&gt; in our query statement.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>USE of ORDER BY in PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Sun, 30 Jul 2023 19:28:49 +0000</pubDate>
      <link>https://dev.to/mmmalik45/use-of-order-by-in-postgresql-5da1</link>
      <guid>https://dev.to/mmmalik45/use-of-order-by-in-postgresql-5da1</guid>
      <description>&lt;p&gt;In this article I will share how Order By clause can be used in the PostgreSQL.&lt;br&gt;
Let's get started...&lt;br&gt;
When a query is run to return the rows as output in a &lt;code&gt;SELECT&lt;/code&gt; statement, it returns data in unspecified order. So &lt;code&gt;ORDER BY&lt;/code&gt; clause is used to sort the data of the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of ORDER BY clause&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
    select_list
FROM
    table_name
ORDER BY
    sort_expression1 [ASC | DESC];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As from the syntax, it can be seen that first step is to specify a sort expression that can be a column or expression which you want to sort just after the &lt;code&gt;ORDER BY&lt;/code&gt; clause.&lt;br&gt;
After specifying the sort expression, &lt;code&gt;ASC&lt;/code&gt; or &lt;code&gt;DESC&lt;/code&gt; is used to sort the rows of output in ascending or descending order based on the desired output you want.&lt;br&gt;
It is noted that if you miss writing the &lt;code&gt;ASC&lt;/code&gt; or &lt;code&gt;DESC&lt;/code&gt; option then by default &lt;code&gt;ASC&lt;/code&gt; is used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Suppose we have the &lt;code&gt;customer&lt;/code&gt; table with following attributes in the database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O5RwQ_dt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ycaiao4yb8htq0ld6pj.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O5RwQ_dt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ycaiao4yb8htq0ld6pj.PNG" alt="Image description" width="243" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Using &lt;code&gt;ORDER BY&lt;/code&gt; to sort rows by column:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
       first_name,
       last_name
FROM
       customer
ORDER BY
       last_name DESC;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query returns the rows after those rows by values in the last name column in descending order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nJ6LtN6f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjwprthxil6u6uov5ub9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nJ6LtN6f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjwprthxil6u6uov5ub9.png" alt="Image description" width="383" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Using &lt;code&gt;ORDER BY&lt;/code&gt; to sort rows by expressions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    first_name,
    LENGTH(first_name) len
FROM
    customer
ORDER BY 
    len DESC;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above query returns first select the first names and their length. And then It sorts the rows by the lengths of the first names in descending order. The name with highest length will be on the top and so on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f3xF7LfS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfdr1s4r60n3otdj6p66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f3xF7LfS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfdr1s4r60n3otdj6p66.png" alt="Image description" width="274" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this tutorial we learnt about the use of &lt;code&gt;ORDER BY&lt;/code&gt; clause in PostreSQL by column as well as by expressions.&lt;/p&gt;

</description>
      <category>postgressql</category>
      <category>tutorial</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>Advantages of PostgreSQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Sun, 30 Jul 2023 19:04:00 +0000</pubDate>
      <link>https://dev.to/mmmalik45/advantages-of-postgresql-1jii</link>
      <guid>https://dev.to/mmmalik45/advantages-of-postgresql-1jii</guid>
      <description>&lt;p&gt;In this article I will be sharing the benefits of using PostgreSQL as database. So let's just get started...&lt;br&gt;
&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
PostrgreSQL is a free and open-source advanced relational database system. It supports relational as well as non-relational (JSON) queries.&lt;br&gt;
Let's look at some of the advantages of PostrgreSQL which makes it standout from other databases.&lt;br&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PostrgreSQL is flexible solution with extension which can cover every potential use case. You can even write your own extension if you have a very particular requirement such as support for a data type or some special logging functionality.&lt;/li&gt;
&lt;li&gt;PostrgreSQL can be used as both relational database management system (SQL) or as a NOSQL database solution such as storing the JSON documents. This flexibility of PostrgreSQL can reduce the cost. Using single database management system means that it cut the cost of managing, setting up and updating multiple database solutions. All can be done from a single place.&lt;/li&gt;
&lt;li&gt;For critical productions such as hospitals, government agencies and financial firms, the privately supported solutions of PostrgreSQL can be used. These versions of PostrgreSQL provides additional security features, high-availability and resiliency.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So above mentioned are some of the benefits of using PostgreSQL.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>postgressql</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>PostgreSQL vs MySQL</title>
      <dc:creator>Malik M</dc:creator>
      <pubDate>Fri, 28 Jul 2023 14:40:02 +0000</pubDate>
      <link>https://dev.to/mmmalik45/postgresql-vs-mysql-4k3i</link>
      <guid>https://dev.to/mmmalik45/postgresql-vs-mysql-4k3i</guid>
      <description>&lt;p&gt;In this article I will be explaining the difference between PostgreSQL and MySQL based on their architecture and performance.&lt;br&gt;
Let's get started...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
PostgreSQL and MySQL are two popular choices whenever we want to choose the Database Management System for the application. &lt;br&gt;
Both of these databases has their own strengths to cater the different use cases.&lt;br&gt;
Both are relational database management systems (RDBMS), but PostgreSQL stands out as an object-relational DBMS (ORDBMS) with advanced capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Architecture and Performance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL:&lt;br&gt;
As PostgreSQL has ORDBMS architecture it provides advantage over MySQL. PostgreSQL does not requires read or write locks, which allows multiple users to access and modify data simultaneously without any inconvenience. These features of the PostgreSQL make it ideal choice for the environment where there are multiple users working simultaneously on it.&lt;/p&gt;

&lt;p&gt;MySQL:&lt;br&gt;
MySQL relies on write locks to achieve concurrency. It can lead to a reduction in the number of concurrent operations per process, which reduces its performance in write-heavy scenarios. To make it well suited for write heavy scenarios, considerable resources are needed to be added for that. And MySQL excels in read-heavy operations which makes it suitable solution for applications which are simple and relies only on data retrieval operations for the most of the time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Speed vs. Data Integrity:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MySQL:&lt;br&gt;
MySQL's design prioritizes speed over data integrity and standards compliance. In simple implementations, MySQL can outperform PostgreSQL due to its lightweight approach and lower memory usage. For applications that primarily read and display information from the database, MySQL may offer superior performance.&lt;/p&gt;

&lt;p&gt;PostgreSQL:&lt;br&gt;
PostgreSQL, on the other hand, sacrifices some speed for the sake of data integrity and compliance with industry standards. when creating a new process it allocates a large amount of memory (almost 10MB)  for each connection, which can lead to high memory usage. Well, this trade-off ensures that data is handled with strict adherence to consistency and reliability, making PostgreSQL a preferable choice for applications where data accuracy and reliability are critical.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Write-Heavy Operations and Data Warehousing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL:&lt;br&gt;
PostgreSQL excels in write-heavy operations, which makes it well suited for applications which requires large number of write transactions. It also supports concurrent writes and robust transaction management. This makes it ideal for systems where  real-time data updates are required.&lt;/p&gt;

&lt;p&gt;MySQL:&lt;br&gt;
As discussed above MySQL performs well in only read-heavy scenarios. Whereas PostgreSQL performs well in the write heavy scenario. As PostgreSQL is an ORDBMS, this makes it a favorable choice for data warehousing solutions.&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
In short, PostgreSQL and MySQL, both are powerful database management systems, but their strengths lie in different areas. PostgreSQL is an excellent choice for the reliable, and database which is feature-rich to handle large-scale and complex applications. Whereas, MySQL is best choice for the applications which are simpler and read heavy operations are the critical part of it.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>postgressql</category>
      <category>discuss</category>
      <category>database</category>
    </item>
  </channel>
</rss>
