Question of the day (MySQL 02)

What do you understand with the term CTE Table? Write an example query for creating a CTE table and applying Rank() and Dense_rank() functions.

1 Like

The CTE TABLE means the common table expression. It is used to create the structure of a new table by using the existing table. It reduces the all the normal table creation syntax of each column name and data type size. It is not much useful for small tables but when the tables have a greater number of columns then it is useful. It also used to create a table with our desired data.
let us consider a students table consists of data of various branches of students.
my requirement is to create a table for cse students then use CTE it will create the table along data.
this is the table of student scores:
image
this is the china_students table created using CTE


demonstration of rank:

demonstration of dense_rank:

note: some part of queries may vary for oracle and mysql, these are oracle queries

2 Likes

@thirumal202018
Very good explanation.
Keep it up :heart: