 Assalamu alaikum. How are you? I hope you are fine and enjoying life and this course as well. Well I cannot say anything about life but if you have any problem about this course you have got all of our contacts, contact us and we will try to sort it out. Today we are going to do the lecture number 30 of this course. The course is Database Management System and the code is CS403. At the end of previous lecture we were discussing the Order by Clause of the Select. The objective of the Order by Clause is to display the output of the Select statement in a particular order. I mean it will be sorted on the basis of value of some attribute. It could be one value, it could be one attribute or more than one attribute but anyway the output will be in the descending or ascending order. I hope you know what is what is meant by descending and ascending order. So we discussed the format of the statement yesterday and today we are going to see the examples of the Order by Clause. So let us start today's lecture. Now this is a query basically display the student's data in the ascending order of names. Again this is the requirement of the users and notice your job to transform this requirement into the form of a query. So how do we do this? This is select star from student. Well this part of the statement it accesses data from the table and Order by student name. As we discussed yesterday in the format of the statement we saw that there are two possibilities ascending or descending. I mean whatever values you are sorting on the basis of which the value will be higher or lower and by default it is ascending. This means that if you are sorting on the basis of a name the name starting with A will come first and then those with B and C and like that. And obviously it is obvious that the alphabets and the characters do not have any name in the table that start let us say with E. Obviously it will be skipped. So by default it is ascending order but in some situation if you want to have the output in the descending order then you will have to mention the descending specifically. So the output of this statement is here is the output. If you see here that we have got all the attributes of all the records because we do not have given any condition that is why all the rows are included in the output at the same time because we have given the star we have not used any attribute names that is why you are seeing all the attributes as well. So all the attributes all the rows but the order by clause played its role and you are seeing these records in the order of name. And because we have two amjits that is why we have got amjit at first position and amjit at second position but obviously they are two different amjits and that is ensured from the student ID. See the surety is from the student ID that they are two different amjits because you cannot be sure seeing the just father name because there may be two different students having the same name and the same father name but the surety that they are two different people this is assured by the fact that they have got two different student IDs when they have two different student IDs it means they are two different records. Then we have got RFZIA then MLE then SADIA and all the way through. So this is how you get the output in a particular order and again the thing that I said yesterday as well that the data in the original table it stays as it is as it was before this command. This command source orders the data only for the display purposes it does not affect the storage of records in the actual database file I hope it is clear to you. Now here I am giving you a practice theory display the name and CGPA of students for all those students who are in the second or above semesters in the descending order of names. Now if you analyze it a little bit what we want is name and CGPA these are the two things after that it is said for all those students who are in the second or above semester. This means that as we have just done the practice theory, there was no where clause there but here in this query in this requirement we only need the names and CGPA of those students who are in the second or above semester. It means you can guess it very clearly very easily that there is a need for the where clause as well okay and the final part says in the descending order of names. So this means that now you have these three different parts of this requirement. According to this query you will write, so I hope that you will touch every component of this part appropriately. See you have got the idea of functions from any programming language. Functions are normally defined in two types one is your built-in built-in means that are provided by the language or in this case by the dbms and the other functions are written by the user. So they are called user-return or user-defined functions and you must have definitely used them. For example, you have done your course or you have read your data structures and when you have written different programs you must have used your functions. Likewise the SQL also supports the functions and basically the idea of function is that when we are talking about the built-in functions. The built-in function is a pre-written program. Pre-written means that is a part of the software tool that you are using. Let's say if you are using C then you get it in some library format or if you are using SQL server or Oracle then in system software or in software there are some functions or some programs which are built-in which are written from the beginning and they are defined to do some special work and the definition of those functions included in the documentation of that particular tool. For example, if you include the functions in the SQL server then the description of those functions will be in the books and in the online help house. So normally you are not interested as a user. You have no concern how the function is practically implemented. Always know. The only thing that you need to know is how to use this function. How to use means how to call it. What are the arguments, what are the things that you will provide to this function and what it will result to you as an output. So for a function it is enough. In any language, in any environment. So this is the only thing that you have in the SQL server. Those are some built-in functions provided and we will do some examples of them. As I said earlier that we are not covering all of them and it is not objective that we are covering them because we are not doing some course on the SQL. We have associated it as a tool, some lectures for it. Let us see. Accepts, arguments and returns the result. This is a normal way of working of a function. Categories of functions. And mind it, they are specifically with respect to the SQL server. This is the reference here because in some other tool it can be categorized in some other way. Although this categorization is very general. It may be implemented somewhere else as well. But specifically it is for the SQL server and in some other place depending on the arguments and the return value. The functions can be categorized into mathematical. There are some examples here but there are some examples. Not all of them. If you look at the documentation you will see a lot of them. See, the approach of categorizing the function is almost the same in everywhere. It means that the type of argument it accepts and more importantly the type of value it returns. Because sometimes it turns out that the function accepts different values and returns different types. Normally the type defined in the category, the function's category is defined on the basis of arguments and return value of both. Now the categories in the SQL server as you saw on the screen are mathematical. In addition, you have the function of text or string type. Similarly, you have the mathematical. You have the system and the conversion. So mathematical, date, text, system, conversion. So these are the categories specifically in the context of SQL server. You will find the same sort of functions in other DBMS as well. You will find different sort of functions exactly the name of the function. And secondly, the argument, the precise argument that it requires, it may vary from DBMS to DBMS. Same be it, different be it. So that is why you will try to use it in the SQL server. But if you are using some other DBMS, then you should try to use the same function as we will read here. But if it does not work, then try to find out the precise or the exact form of the function in that particular tool. Let us go ahead. Now here we have an example in which we are using different functions in the select statement. If you look here, we said select upper student name. Now the student name in your database can be stored in any format, be it in the lower or upper or mix. Like when you use upper. So it gives a sort of uniformity to your output. It is certain that whatever format that I stored in. And the interesting thing is that it is not necessary that all the student names that are stored in your, let's say student table. For example, we have 1000 students' records stored here. So it is not necessary that all the names are stored in the same format in the same style. In fact, it can be that some names are in the lower case, in the upper case, and some mix names are like that. This is a different thing that a good program would have developed. It will take care of that. That it should try to store in the same case. Anyway, so your student name will be in any case. When the output is in the upper case, it will transform it into the upper case. Similarly, we are seeing that what we have used in the father name is lower. This means that if the father name is in any case, for the output, the lower function will transform it into the lower case. And the same thing that I said earlier that whatever functions you are using here, they are only for showing it on the screen. This is only for displaying for the output. The actual data, it remains unchanged. And if you think about it a little bit, if we want to bring uniformity to our data practically stored, first of all we want to do it in the upper and lower case, then what we will do? There are two approaches to that. One approach is that when you write your data entry program, the user who starts doing the data enter the data in the lower case and the upper case. But this is not a good approach. You put restrictions on the user who is more than working through their program, underlying so that the user doesn't even know. So the smart approach is that the program that your data is accepting from the user will accept it. And when you are moving the data to the database and for that what statements do you use? Insert key. So you will do it in the insert that when you get your data you will transform it in the upper case. From this you will get a guarantee that all the data that we have stored in the table is in the same case. Anyway, I was telling you that how do we move the data in a particular case when we are inputting the data into the table. In this case, we have used the upper on the name and the lower on the name. And the address that we are placing as such. And that function is length, convert, character, student address. The first thing I will warn you here is that this approach is again specifically with the SQL server. Don't take this as a generalize. Especially the functions that we are using, the approaches that we are using, if you are using any other tool then this is the activity that we are using by using some other function or by some other methodology. Anyway, one thing you see here is that where the functions are nested. This is called nesting of functions or nested functions. What is happening is that in one function another function is being used. You see that length, convert, character, student address. What is happening is that you have the student address. Now think here that this student address that we have defined as text. We want that the address store of different students has the length, how many characters we want to know. Now the function of the length in the SQL server is not being applied on the text. What did you do? We transformed the text data into character and when it was transformed then we applied length function on that transformed data. Again, your original data that is stored in the table, that still remains as text. But you just for your requirement purposes, for the time being, for that particular moment you transformed it into a data type that is acceptable to this particular function, length. Or even the convert or len function we are using, again they are SQL server dependent from student. What is the output of this? Look here. Since you see that we have columns headings if you note that we had a student name on the upper side, we did not give a column so that is why it is called no column name. Similarly, we have given a father name you can see that all the lower cases are coming and since we did not give an alias, that is why it says no column name. The address we are seeing as such. And the length of the address is written here 11, 6, 7 and like that. So you have seen that we have different functions. Let us make a select statement one thing. The second thing is that the name and their arguments are tool specific. They may vary from tool to tool. And the third thing is that we can do the nesting of the function as well. Means we can call a function within a function and it can carry on up to any level. What you have is called single row function. The meaning of single row function is that they are functions that if you have a table then those functions are applied on every row of the table. How many rows are there? 1, 2, 10, 100,000, how many rows are there? Each row has a different application. For example the upper, lower, length all these are row level functions. So this function will be applied on the student name so this function will be applied on the student name attribute of every row. And it will transform whatever form the student name is stored in it will transform it into the upper case. Likewise the lower and same is the case with the length and convert. The function that we call the aggregate functions those functions do not apply but they are applied on a group of rows on a collection of rows. Now that collection of rows has a camera it could be the entire table. Even if there are 10,000,000 rows when we apply a single aggregate function it will be applied on the entire table on all the rows in the table and it will return a single value. The single row function it is applied on a single row and returns a value against each row whereas the aggregate function it will be applied on a group of rows and that group of row I told you it can include the entire table. And for each group of rows on which an aggregate function is applied it will return a value against it. For example, we have 100 rows it can be applied on 100 rows and return a value. It can be applied on 10 groups and return a value against each group and even the group size needs not to be exactly the same it can be 15, 1, 2, 25, and like that. So if we define it briefly then we will say it is applied on a set of rows, on a collection of rows and results a single value. Apart from that you have row level functions or single row functions they are applied on each row and obviously when they are applied on each row it will again return a value against each row. Let us see what are the examples of the aggregate functions and how they are applied. Operator on a set of rows and return a single value like average, sum, maximum, minimum, standard deviation. Attribute list cannot contain other attributes if an aggregate function is being used. I will explain this in a little bit. As you can see on the name of the functions it is clear from their name that what is their objective. For example, when we say average. So the attribute you will specify this function will return the average of the values of all attributes of that attribute in all the rows of the table. Again if you say average age this means that the average of all the attributes will be returned to you and obviously that average will be a single value. If you say sum sum means that again it will give you the sum of the group of rows. The group of rows can also be a table and as I told you certain groups can also be used. Likewise maximum, max and min maximum value, minimum value and standard deviation will return the standard deviation of that attribute. Here you can see an example of an aggregate function which is cgpa. Here you have given it a column and max cgpa as maximum cgpa from student. Now you can see that you have used different functions like you have used the average and the maximum. And on the same attribute no problem. The thing is these are the aggregate functions they will be applied on the same attribute. And one thing you have to take care of is that the type of requirement you have to give it the same type and give it the same argument. For example, on the date your average and maximum will not be applied. Apply the average on the number or numeric type data. This will be the output. Now here you can see that you have two results. Again these functions are applied on all the rows of the table because you have not done any further grouping. So all the rows whether it is 1 or 10,000,000 in all the rows when you have the attribute on cgpa you have the average of 2.91 and it is a big number. When we talk about the maximum cgpa one of the rows where the maximum value of cgpa was stored was picked and displayed here. In this it will be inconvenient that the average cgpa is written in a very long value. So we will have to do something to get it in a reasonable format. And that is again the approach in SQL server. If you want to ask how to do this work then you have to look at the tool in which you work. Now the other written query is bringing it to a reasonable shape. What is that? Convert Decimal 5, 2 which means the second argument is the average cgpa. Convert is a function that will transform it into the first argument. Now what you have said is that you transform the average cgpa in what form? Decimal 5, 2 means total space 5 and after decimal 2 places. So you have transformed it in this shape. The rest is the same as the average cgpa and the maximum cgpa is this one. It is easier to read or understand. These are the things that with the passage of time with practice, you will think by yourself. Again I am saying that the user will not say use this function and that function and give me this format. And it is possible that the user will not tell you to give 2 digits. It is possible that if you display it then the average cgpa is coming. But as a designer and developer you have to use your aesthetic as well to see how it looks in reading. So in that way the artistic touch or the beauty that should be included in it. It is not like accuracy is first thing and efficiency is second option and second priority. And the third thing is how it looks. As you have seen the example of aggregate functions you have seen that the aggregate function is applied on the entire table on all the rows in the table. Now we have group by clause. This is also a clause in the select statement. In that it gives you this provision that instead of applying a function on the entire table on all the rows in the table you can create a different group in that table. And then it will be that the aggregate function that you have used that function will be applied on these groups. Those groups which you will create on a special basis. It is not like you form the groups on the basis of value of some attribute. Similarly, if you are storing the data of employees then if you say that I give the average salary of all the employees what will happen is that the average function that you will apply on all the rows in the table is the average salary of all the employees. But the second situation is that you want the average salary of the employees department-wise. For example, we have 15 different departments and we have 6000 employees who work in 15 different departments. I want to see what is the average salary department-wise. Now you will again apply the average function but also that group by department number. Instead of applying the average function on the table, the group by clause on the basis of all the departments in which the department number is the same will form a group. As I said before, it is not necessary for the employees to have equal records. So all of them will be equally divided. No! It will depend upon the situation that whatever data is available to you, you have to apply the code of 10, 20, 30 and so on. So if you have the employees' records let's say department number 10 and the first 6,000 of them is 2000. It is a very broad department. So this group will become 2000 employees and then the average function will be applied on the salary. So a special department of employees will automatically become a group and then the average function will be applied. First in this way, you have department number 20 and the first 15 employees. Again, there will be 15 people in this group and then on these 15, the average function will be applied and the departments will be a group and this function will be smaller and now you will get the output. When you applied the aggregate function then you got a single value. Why? Because the aggregate function is being applied on the entire table on all the rows. But this time you won't get one value. In fact, all the groups depend on how many groups they will be. There are 15 of them. They can be more or less. So all the groups of each group you will get a single value. So this means that on one side you applied on the table and on the other side you formed the grouping on any basis and on that group your aggregate function will be applied. Similarly, if we take our student example then we can say department wise sorry, program wise which students who are MCS men or BCS men you want program wise on the average CG page. So when you said on the average CG you got a value for the entire table. But this time if you say group by that is a program name then you will get the average group size. Let's see the example. Here is again an example in which you see you have used an aggregate function and that is the average CGPA. In this if you see we have also included the student name in the select list. Well this is something that we need to discuss. Dear students, when you use an aggregate function in that the select list of things that you want to display on the screen they identify or write you have to be a bit careful. Because when you use an aggregate function with that a simple attribute cannot be used in normal circumstances. Whenever you are using an aggregate function whether it is maximum or minimum when you are displaying that with that a common attribute can be used in normal conditions without making some special arrangement we will discuss what are those arrangements. Without that you cannot display it with an aggregate function. Why? The reason is that we have already discussed it that your aggregate function that is applied or that is implemented on a group of rows. You have 2, 4, 5, 10, you can have thousands of rows on which it is applied and after that it returns a single value. The question is that if you say that I have used an aggregate function and with an aggregate function you also give the name of a simple attribute common attribute. For example here we have said that select student name common average CGPA because you have not given any condition yet the average CGPA function it will be applied on all the rows of the table there are 20, 100, 1,000,000 rows When you said average CGPA and you also said student name you must have noticed that the average CGPA is being applied on lets say 1000 rows which will you get the name of. If you have 1000 records so all the records have name. Then when we say We have to give the average CGPA 2, which will be applied on thousands of codes and get a value. But how can you combine a simple attribute like slurname with this aggregate function? The DBMS gets confused. If I am giving the average CGPA, I am giving it on thousands of days. So who should I show the name of? Should I show the name of thousands and show it equally? Well, this is wrong. That is why you should keep in mind that you can't use the name of a simple attribute with any aggregate function. This is what you should keep in mind. The second meaning is that we can include an attribute in any case. The case is when we are using group by clause. So when we are using group by clause, we will give an attribute after group by clause. We are saying that we can use any aggregate function, whether we have used one or two. For example, we have used the average and maximum together. We can use three or four of them in one statement. So when we say group by clause, we mean that whatever function you have, you can use them in groups. And what is the group being used for? You have given the name of that attribute in group by clause. For example, as I said, group by department number. What is happening in that case? Your group will be based on department number. And then your aggregate function will be applied to every group. Simple. Now there is no confusion. Now when we are saying that the aggregate function value will be returned, what value will we represent with that? So you can include that attribute with the aggregate function in the select list. That you have used in the group by clause. Then it becomes simple. We have said that we want to do group by on the basis of department number. So if first we had department number 10, 20, 30, we have formed a group like this. All the employees are there. So we have said that department number, comma, average salary. And then we have said group by department number. Now it is easy that whatever you will have an aggregate function value, with that you have to return the department number attribute value. The same value which was the basis of that group. Simple. What will happen? If first in this case, we will have 10 department number. And 7th place, average salary which is the department number of 10 employees. Then 20, average salary, 30, average salary and like that. So whatever you are seeing here, we have this query here. This query won't work. It won't work. Why? Because it is the same condition which is going to be confirmed. That the DBA will not know that I am giving the average salary of thousands of people. You are asking for a name. Whose name should I give? That's why this query won't work. That's why you don't have to write this type of query. So this is an example. You have the query which will work here. Select program name. Now program name is a simple attribute name. Along with that, you have used an aggregate function. That is maximum CGPA. Apart from that, you have used one more aggregate function. That is minimum CGPA. Now you have used two aggregate functions. I have already told you that if you have used one aggregate function in the select list, you can't give a common attribute name. So in this clause, you have given the name from the student. Along with that, group by program name. It is a simple thing. What will happen? On the basis of program name, all the records of the student have a value of a program name. You will form a group based on that value. MCS students, BCS students, MBAK, BITK, BCEK, MSEK, and like that. So on the basis of every value, whatever attributes you have, you will form a group based on every value. The rows having the same value of the program name attribute, they will form one group. And whatever maximum and minimum functions you have, they will be applied on these groups. You have group by maximum CGPA and minimum CGPA value. Along with that, you have used a program name. Now, this can be done. Because we have a value of every group's value. It is a value of aggregate function. Against that, we have got a single program name value to be displayed. Now, it is easy. It can be done. Now, look at the output. Now, these are the rows that we have got in the student table. All the records are in front of you. And they have only program name and CGPA display. Now, look at this. This is the result that we got from the previous statement that we saw on the previous slide. On that, you see that all the students who are getting the results, you can see that all the different programs in which your students enrolled, they are all in front of BCS, BITK, MBAK and MCS. And if you look at the data, you can see that in BCS, if you look at the left side, in BCS, we have one student. In MBA, there is also one student. In BITK, there is also one student. In BITK, there are two students, but they are not in CGPA. And in MCS, we have four students. So now, it means that the exact size of the group, it varies. It can vary in different groups. But the thing is that the group will be on the basis of the value of the attribute that you have specified in the group by clause. One thing. And the other thing is that on every group, the function given by you will be applied and they will return single values. And in this case, now you see that the program name here, now you can display it. Because now the group is increasing. I hope you have cleared this. Having clause. Now you have read the where clause. Where clause basically happens is that you have to check every day in your select statement. Having clause, we only use it if you want to apply some check or some restriction on the group, on the value of group. In that case, instead of where, we use having. So we can restrict groups by using having clause. Group satisfying, having condition will be selected. Fine, as it was with where. The difference is that where is with normal table, it is with rows. But your having is with group by, it will come with having later. And in that, you put the condition on group. Placement wise, keep in mind that having can come before group by. But generally, we are after having group by. We have a general format here. You are seeing that select and select list. This is what happens in to new table. Leave it for now. Then from table source. Select and from. These are the clauses. Compulsory is required. Without any square brackets. Because they are required. Or select or from capital letters. That we have to give as such. Or select list or table source. In lower case. Now where we have studied. This is optional. Group by, we have just studied. Again this is optional. We have ordered by. Having, having search condition. What do we mean by search condition? That we have already discussed in the previous lecture. That the detail of that search condition. How it is formed. So having. You apply a condition. But this condition. Is applied on the group. Which is formed on that. And then the same thing. Your groups will satisfy this condition. They will be selected. And obviously they will not be selected. See this example. You said that select program. Minimum cgpa, maximum cgpa. It is written here. From student. And here group by program. This is what we have done. This is having. Maximum cgpa. Greater than 3. Now see. Your function you have used. Aggregate function was minimum maximum. Now what you have applied. The value of groups. Is applied on that. You cannot say here. You cannot say here. Having cgpa. Greater than 3. Because cgpa. It is associated with each and every row. So here you cannot specify. That you cannot apply the condition of the row. You have to apply the condition of the row. That you will apply on the. Using the where clause. So what we have said. Maximum cgpa. Greater than 3. And if you see. Earlier we had. Four groups. When we have attached. Having clause. Maximum cgpa. Greater than 3. Now we have got. Just two rows. Because these are the two groups. Maximum cgpa. Greater than 3. So here you have. How do we use the having. Where and having can be combined. The difference is both. In both. Where is applied. On all the rows Where's having is applied. On the for the groups. So when we combine. So. Where. Where made rest właśnie. Protecting. Going in a. A liquid. These are that. When you have given the wear clause, the condition you have given in the wear clause, that condition will be applied on all the rows. And the rows which are selected from this, only those rows will be forwarded to the aggregate function. And your aggregate function will be applied on those. Now you have certain values in which you have used the group. So in different groups, the rows will be divided and the aggregate function is applied on those rows. But again, you have a second barrier by the having clause. Now the condition you have applied here, that is basically on the groups. Now the condition given in the having, the groups which will satisfy you will be finally displayed. But it will always be that first wear on individual rows and then having on the groups. If you ever need to combine them, then let's move on. Accessing multiple tables. Till now, all the forms of select statement that we have done, your data was in one single table. And this form of access is relatively simple. Do you know that the data is in one table? And while using the forms of select, you have to pay data from one table. But in real life, things are not that simple. It is not that you always fulfill all your requirements from one table. And the reason for this is that when we did the normalization on the basis of normalization, we split the things in different tables. And basically, that was due to the efficiency purposes. And secondly, so that we can avoid the anomalies. But the requirements are that you will not get all the data from one table. Many times, rather more frequently, you have to access data from the multiple tables. And then I will tell you again that the user is not concerned that the data is in one table, in two, or in how many? No, the user simply has to tell you their requirements that they need this data. Okay, you had that requirement. Apart from this, the data that has to be stored in this organization, you also identified it with your analysis phase. And then for the efficiency purposes, you divided it into different tables. Now, when you have designed it, you have also made its physical database design. Now, you have to see how I have to fulfill the requirement. And most of the time, your required data will be stored in the booktables. For that, you have to pick the data from there. If you remember, when we read the relational algebra, we read the Cartesian product and the different forms of it. Like joints, different forms. The same things now we are going to do in the SQL. And look at the thing that you have read, the referential integrity constraint. It plays a very important role in this. The data is in your different tables. But when you have to pick it from different tables, you will pick the same data that is related to it. And if you remember a little bit, the relational algebra had different operations. And it was the same thing that is related to it, linked to it. We ultimately pick them. So in the SQL, we are going to do this. How do we access data from multiple tables? And multiple tables means it could be 2, 3 or even more than that. So what are the different forms of data access from multiple tables? One is Cartesian product. We have read this in the relational algebra. Inner joint, outer joint, full outer joint, semi joint, and natural joint. In this, inner joint and natural joint, we have already discussed that these are different forms of equi-joint. So here, you cannot see equi-joint precisely, but you can understand that it is replacing the inner and natural joints. Cartesian product. As you will remember from the relational algebra, what happens in Cartesian product is that no specific command in SQL for the Cartesian product. We had seen that the symbol of the multiplication or the verb of the product is used. Here, we do not have a command. We just use select. And what does Cartesian product do? You know that every row of one table will be combined with every row of the other table. So simply give the names of the tables involved. Cartesian product will be produced. Produces m cross n rows. If we have 10 rows in one table, and 15 rows in the other, then when we take the Cartesian product, or the cross product, then we have 150 rows. And when we talk about attributes, then all the tables will be included in the attributes. This means that if we talk about the number of attributes, then that will be a plus b, where a is the number of attributes in table 1, and b is the number of attributes in table 2. So the sum of both will be as many attributes as the output. And if we talk about the number of rows, then the number of rows of both tables will be as many as the product. Because every row will be of one table, and every row will be of another table. This is a simple command. You can select star from program, course. As I told you, there is no specific command here. Without any condition, you can select program, course, and give names of all the tables. Then that is equivalent to the Cartesian product. And where we have given star, again you can use the attribute list. If you want a particular attribute, then you can take it here. You can see here, the cross product of program and course, or Cartesian product. Because we cannot display everything on the screen. But you can understand that the number of rows in the program and the number of rows in the course table, the product of both of them will come to the output every day. And all the attributes of both of them are included in it. And you can see that the program name attribute has been included in both of them. So it has come to the output from both of them. Certain columns can be selected. The program column name needs to be qualified. For example, you saw that when we gave the star, it was with the star that you have all the attributes. But first you want some specific attributes. So in that case, you will have to give their names. But if you have some attribute name which is common, and especially the chances of this are more in the case of the primary forum that their names will be the same. So if you are giving a select list, meaning you are giving the name of the attributes specifically rather than star, in that case, if their name is not common, then you can simply use the attribute name. But if the name is same in both the tables, in that case, if you only write the name of the attribute, then DBMS gets confused. So it will give you an error. This means that if you have to give the same attribute name in your list, then in that case, you will have to write the name of the table, dot attribute name. Similarly, it can be applied to more than one table, and even can be applied on to the same table. We will read that how it is applied on the same table. But as I said, if we have to do it on three tables, then the name of the first table, comma, the name of the second table, comma, the name of the third table, then your Cartesian product will be applied on three tables. For example, here we have a select star from the student class program. We have mixed the tables. We said that we will have the Cartesian product of these three. And it will be the same. If we have ten days in the student class, and ten days in the program, and ten days in the class, then the output we have will be one thousand days. Because every day of the student, every day of the class, and every day of the program, every day of the program, then we will have a total of one thousand days. Dear students, let's conclude today's lecture here. In today's lecture, we started reading the different clauses of the select statement. We started with the order bias. We saw its example. In addition, we have read here group functions. What is the objective of group functions? How do they work? In addition, we have read group by clause with group functions. How? Rather than applying the aggregate function on the entire table, we can apply this aggregate function on different groups of rows. So, for that purpose, we use the group by clause. And after that, we also studied the having clause, which your group by clause is used with it, and it imposes conditions on the groups. In addition, what we were discussing at the last minute, was how can we access data from multiple tables? And in that, the different forms of the joint are involved. So far, we have studied just the Cartesian product. And as such, this is not so useful, but the other forms of the joint are more useful and more frequently used. We will discuss these in our next lecture. I will be with you more often. Allah Hafiz.