Sub-Queries, Derived Tables, and Common Table Expression Examples

Common Table Expression (CTE) Example

In this example, we will explore some useful select queries that comes handy when we want to retrieve data from different tables. There many ways one can form select queries that returns the same result. For this article, we will use Microsoft’s Pubs database and explore Sub-Queries, Derived Tables and Common Table Expressions (CTE). We will explore these queries one by one.

Ranking Functions Examples – RANK, DENSE_RANK & Percentile

SQL Dense Rank Example

Ranking Functions are useful to provide ranking on the table columns based on the value stored in it. Say, for example, let us say a table is having students id and their Total Marks as separate columns. Now, it is meaningful if we apply the these function on the Total Marks column rather than Student ID column. With these Functions, we can easily find 2nd maximum, or 4th maximum marks. The Ranking Functions are available in SQL 2005 and later versions.

Table Join Explored With Examples

Self Join SQL Example

“Table Joins” are useful for bringing data together from different tables based on their database relations. First, we will see how the join operates between tables. Then we will test the Order of Execution when Join and where condition both lies. Finally, we will move our exploration to Importance of the Join order. It is a good idea to know about database table relationships before reading this article.

Learn How to Use Order By Clause and Group By Clause

SQL Query with Aggregate, Group By, Order By and Having with Where conditions

1. Introduction to Grouping & Sorting In this article, we will explore group and sort the result of an SQL query. The Order By informs SQL engine to arrange the query output in ascending or descending order. To put it differently, the…

Table Relation – One-to-One, One-to-Many, Many-to-Many Explained

One To Many Relation

RDBMS Database supports the relationship between tables. One can do this by linking the columns. This article shows how to modal the relationships One-to-One, One-to-Many and Many-To-Many with examples. The relationship One-to-Many can also be seen as Many-to-One.