<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=RDBMS-PostgreSQL%2FC2%2FSelect-with-Aggregate-functions%2FEnglish-timed</id>
		<title>RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=RDBMS-PostgreSQL%2FC2%2FSelect-with-Aggregate-functions%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;action=history"/>
		<updated>2026-04-17T13:33:43Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;diff=45703&amp;oldid=prev</id>
		<title>Sandhya.np14 at 15:41, 5 February 2019</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;diff=45703&amp;oldid=prev"/>
				<updated>2019-02-05T15:41:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;amp;diff=45703&amp;amp;oldid=45659&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Sandhya.np14</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;diff=45659&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot;{| border=1 |  '''Time'''  |  '''Narration'''   |-  | 00:01 | Welcome to the''' Spoken Tutorial''' on''' Select with Aggregate functions.'''   |-  | 00:07 | In this tutorial w...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=RDBMS-PostgreSQL/C2/Select-with-Aggregate-functions/English-timed&amp;diff=45659&amp;oldid=prev"/>
				<updated>2019-01-30T11:04:00Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| border=1 |  &amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039;  |  &amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;   |-  | 00:01 | Welcome to the&amp;#039;&amp;#039;&amp;#039; Spoken Tutorial&amp;#039;&amp;#039;&amp;#039; on&amp;#039;&amp;#039;&amp;#039; Select with Aggregate functions.&amp;#039;&amp;#039;&amp;#039;   |-  | 00:07 | In this tutorial w...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
|  '''Time''' &lt;br /&gt;
|  '''Narration''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 00:01&lt;br /&gt;
| Welcome to the''' Spoken Tutorial''' on''' Select with Aggregate functions.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 00:07&lt;br /&gt;
| In this tutorial we will learn more '''clauses''' that can be used with the '''select statement, '''such as- &lt;br /&gt;
&lt;br /&gt;
'''Distinct''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|00:16&lt;br /&gt;
| '''Between''' &lt;br /&gt;
&lt;br /&gt;
'''Like''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|00:19&lt;br /&gt;
|  '''In''' &lt;br /&gt;
&lt;br /&gt;
'''Is Null''' and  '''Aggregate functions''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 00:26&lt;br /&gt;
| To record this tutorial, I am using &lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 14.04''' operating system &lt;br /&gt;
&lt;br /&gt;
'''PostgreSQL 9.3.x''' &lt;br /&gt;
&lt;br /&gt;
'''pgAdmin 1.18''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 00:41&lt;br /&gt;
| To follow this tutorial, you should have basic understanding of database and tables. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|00:48&lt;br /&gt;
| For more details, refer to the '''RDBMS – PostgreSQL''' series on this website. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 00:55&lt;br /&gt;
| Let’s begin. First we will learn about the '''DISTINCT''' clause. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:01&lt;br /&gt;
| '''DISTINCT keyword '''is used in the '''SELECT statement '''to list distinct and unique values. &lt;br /&gt;
&lt;br /&gt;
It removes the duplicate rows or column values from the query result. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:18&lt;br /&gt;
| The syntax is as follows: &lt;br /&gt;
&lt;br /&gt;
'''SELECT DISTINCT column-names FROM table-name WHERE [condition]''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:28&lt;br /&gt;
| Let us open the '''pgAdmin '''for the demonstration. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:33&lt;br /&gt;
| Click on the '''SQL''' icon to open the '''SQL Editor.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:38&lt;br /&gt;
| Type the code as shown here. &lt;br /&gt;
&lt;br /&gt;
This '''select statement '''will retrieve the unique city names from the '''students table'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|01:48&lt;br /&gt;
| It will eliminate duplicate values from the specified column i.e. '''city'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:54&lt;br /&gt;
| Let us Execute the query to see the output. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:59&lt;br /&gt;
| Next, we will learn about the '''BETWEEN operator.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:03&lt;br /&gt;
| '''BETWEEN operator''' is used to retrieve values within a given range. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|02:09&lt;br /&gt;
| The syntax is: '''SELECT column-names FROM table-name WHERE column-name BETWEEN value1 and value2;''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:19&lt;br /&gt;
| Let's see an example for between operator. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:23&lt;br /&gt;
| Let's clear the screen and type the code for the query. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:28&lt;br /&gt;
| Say, I want to retrieve details of students who are born between January 1995 and January 1996. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:38&lt;br /&gt;
| Let's see the output. &lt;br /&gt;
&lt;br /&gt;
Notice the output shows the list of students as expected. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:47&lt;br /&gt;
| We will see another example for '''BETWEEN operator.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 02:52&lt;br /&gt;
| This '''query''' will show all rows from the''' students table,''' where the '''cgpa''' value is between 7.8 and 8.5. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:02&lt;br /&gt;
| Let us see the output.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 03:05&lt;br /&gt;
| Notice from the output that the value is inclusive of 7.8 and 8.5. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:13&lt;br /&gt;
| The same '''query '''can also be written as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:18&lt;br /&gt;
| Instead of '''BETWEEN operator''', we can use-  '''greater than or equal to '''and &lt;br /&gt;
&lt;br /&gt;
'''lesser than or equal to operators'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 03:27&lt;br /&gt;
| Execute the query to see the output. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 03:32&lt;br /&gt;
| Next we will learn about the '''LIKE operator.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 03:36&lt;br /&gt;
| '''LIKE operator''' is used to match text values against a given pattern. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:42&lt;br /&gt;
| It allows '''wildcard characters '''to be used within the '''WHERE clause'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 03:47&lt;br /&gt;
| There are two '''wildcards '''that can be used in conjunction with the '''LIKE operator''': &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:53&lt;br /&gt;
| '''Percent (%):''' &lt;br /&gt;
&lt;br /&gt;
The '''percent '''sign matches any sequence of string of any length. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|04:00&lt;br /&gt;
| '''Underscore (_):''' &lt;br /&gt;
&lt;br /&gt;
The '''underscore '''matches a single character. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:06&lt;br /&gt;
| We will see few examples using '''percent wildcard.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:11&lt;br /&gt;
| Suppose I don't remember the exact name of a student. &lt;br /&gt;
&lt;br /&gt;
But I remember that the student’s name begins with the letter ''''Ra''''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|04:22&lt;br /&gt;
| It is very difficult to search the entire '''students table, '''as there are many rows in the '''table.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:29&lt;br /&gt;
| To make the search easy, we can use the '''LIKE operator''' as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:35&lt;br /&gt;
| Here, all the student's names start with ''''Ra'''' and is followed by any sequence of characters. &lt;br /&gt;
&lt;br /&gt;
This is called '''pattern matching'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:48&lt;br /&gt;
| Let us see a few more examples. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 04:52&lt;br /&gt;
| Type the code as shown. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|04:56&lt;br /&gt;
| This '''query '''returns those rows where the students’ names end with ''''la'.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:03&lt;br /&gt;
| There can be any number of characters before ''''la'.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 05:10&lt;br /&gt;
| Let us see another pattern. &lt;br /&gt;
&lt;br /&gt;
This '''statement''' returns all the rows where the student’s name has''' 'am' '''in the middle. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:21&lt;br /&gt;
| Note''' percent '''sign before and after ''''am'''' . &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 05:27&lt;br /&gt;
| Next we will see how to use '''underscore '''to match a single character. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:34&lt;br /&gt;
| This will fetch rows of students whose name has three characters and has ''''a'''' in the 2&amp;lt;sup&amp;gt;nd&amp;lt;/sup&amp;gt; position. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|  05:44&lt;br /&gt;
|  '''Underscore 'r' percent '''matches students whose names begin with a single character. &lt;br /&gt;
&lt;br /&gt;
It is followed by ''''r'''' and ends with any number of characters. &lt;br /&gt;
&lt;br /&gt;
Let's see the output. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 05:58&lt;br /&gt;
| Next we will see how to use '''IN operator.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:03&lt;br /&gt;
| Use '''IN operator '''in the '''WHERE clause '''to check if the value matches any value in a given list. &lt;br /&gt;
&lt;br /&gt;
The syntax is: '''Select column-name from table-name WHERE column-name IN ( value1, value2...)''' etc&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:22&lt;br /&gt;
| Let us see an example. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:25&lt;br /&gt;
| This '''statement''' will return all rows from the '''students table '''  where the city is either '''Chennai, Nagpur '''or '''Hyderabad'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:35&lt;br /&gt;
| It helps to reduce the usage of multiple '''OR conditions''' to get the same result. &lt;br /&gt;
&lt;br /&gt;
Let us see the output &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:44&lt;br /&gt;
| Next we will see how to use the '''IS NULL operator '''in the '''select statement'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 06:51&lt;br /&gt;
| This '''statement '''will list down the records where the data of birth column is empty. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:58&lt;br /&gt;
| In the same way, we can also use the '''IS NOT NULL operator''', as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:07&lt;br /&gt;
| Let us now learn about '''aggregate function'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:11&lt;br /&gt;
| '''Aggregate functions '''are '''PostgreSQL built-in functions.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:16&lt;br /&gt;
| It operates on several rows of a query and returns a single result. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:22&lt;br /&gt;
| '''List of aggregate functions''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:25&lt;br /&gt;
| '''Count''' – It Returns the number of rows in a table.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:30&lt;br /&gt;
| '''Sum''' – Returns the sum of a selected column &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:34&lt;br /&gt;
| '''Max''' - Returns the largest value of a specified column &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:39&lt;br /&gt;
| '''Min''' – Returns the smallest value of a specified column &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:44&lt;br /&gt;
| '''Avg''' – Returns the average value for a specified column &lt;br /&gt;
 &lt;br /&gt;
|- &lt;br /&gt;
| 07:49&lt;br /&gt;
| Switch back to '''SQL Editor''' window. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 07:53&lt;br /&gt;
| Let’s say, we want to count the number of existing records in the '''students table.''' &lt;br /&gt;
&lt;br /&gt;
For that, type the code as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:03&lt;br /&gt;
| The '''count open parentheses asterisk close parentheses function '''returns the number of rows that are fetched by the '''SELECT statement.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:13&lt;br /&gt;
| Execute this query to see the output. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:17&lt;br /&gt;
| There are 14 records in the '''students table.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:21&lt;br /&gt;
| We can also specify the column name in the '''function '''as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:27&lt;br /&gt;
| Once again execute the query. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:31&lt;br /&gt;
| Why is it showing 13? &lt;br /&gt;
&lt;br /&gt;
Because the '''count function '''only counts values which are not '''NULL'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:40&lt;br /&gt;
| Let us see the output when we specify the '''date of birth''' column. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:45&lt;br /&gt;
| Type the code and execute. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:49&lt;br /&gt;
| Here we can see the '''date of birth''' column value is '''NULL''' for the student ''''Ram charan'.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 08:56&lt;br /&gt;
| I have left '''date of birth''' column blank during record creation for this student. &lt;br /&gt;
&lt;br /&gt;
So the''' count function''' displays the output as 13. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:07&lt;br /&gt;
| Next let us see how to use the''' SUM function.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:11&lt;br /&gt;
| Let us clear the screen. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:14&lt;br /&gt;
| Type the code as shown here and execute the query. &lt;br /&gt;
&lt;br /&gt;
This returns the summed-up value of the '''cgpa''' column. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:24&lt;br /&gt;
| You can also give an additional ''''Where' condition''' as shown here. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:30&lt;br /&gt;
| This returns the sum of '''cgpa''' values of the students who are from '''Mumbai''' city. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:38&lt;br /&gt;
| Next, let us find the maximum '''cgpa''' score. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:42&lt;br /&gt;
| This '''select statement '''returns the maximum '''cgpa''' score from the '''students table'''. &lt;br /&gt;
&lt;br /&gt;
9.6 is the highest '''cgpa''' score in the '''students''' table. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 09:54&lt;br /&gt;
| Likewise, you can try the remaining '''aggregate functions '''on your own. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:00&lt;br /&gt;
| With this we come to the end of this tutorial. &lt;br /&gt;
&lt;br /&gt;
Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:06&lt;br /&gt;
| In this tutorial, we have learnt about More clauses that can be used with the '''select statement, '''such as- &lt;br /&gt;
&lt;br /&gt;
'''Distinct''' ,  '''Between''' ,  '''Like''' ,  '''In''' , '''Is Null''' and '''Aggregate functions''' &lt;br /&gt;
 &lt;br /&gt;
|- &lt;br /&gt;
| 10:21&lt;br /&gt;
| As an assignment, write '''select statements''' to Display all columns from '''students table''' where the student name ends with ''''a'''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 01:31&lt;br /&gt;
|  Display the minimum and average of the '''cgpa''' column. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:36&lt;br /&gt;
| The video at the following link summarises the Spoken Tutorial project. &lt;br /&gt;
&lt;br /&gt;
Please download and watch it. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:44&lt;br /&gt;
| The''' Spoken Tutorial Project''' Team &lt;br /&gt;
&lt;br /&gt;
conducts workshops and  gives certificates &lt;br /&gt;
&lt;br /&gt;
For more details, please write to us. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:54&lt;br /&gt;
| Please post your timed queries in this forum. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 10:58&lt;br /&gt;
| Spoken Tutorial project is funded by NMEICT, MHRD, Government of India. &lt;br /&gt;
&lt;br /&gt;
More information on this mission is available at this link. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
| 11:11&lt;br /&gt;
| This is Nirmala Venkat from IIT Bombay, signing off. Thanks for watching. &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>