SQL

SQL (Structured Query Language) is a standard language used to operate relational databases. It includes operations such as database creation, retrieving and modifying data, granting privileges to data.

Thumbnail image for Correlated Subquery

Correlated Subquery

A correlated subquery is a type of nested subquery that uses columns from the outer query in its WHERE clause. While a simple subquery is evaluated only once for each table, a correlated subquery is evaluated once for each row.

Read the Full Article →
Thumbnail image for Understanding Subqueries and Their Types

Understanding Subqueries and Their Types

A subquery – that is, a query within a query – can be of various flavors in Oracle. Subqueries may be simple or correlated, nested or scalar. A closer look at the types of subqueries and their purpose.

Read the Full Article →
Thumbnail image for Select Rows With Max Value

Select Rows With Max Value

Solution for selecting rows based on the maximum value of a specific table column, such as date. See it in action: script to list the latest order details of every customer’s orders.

Read the Full Article →
Thumbnail image for Why the SQL WITH clause is not exactly like a function definition

Why the SQL WITH clause is not exactly like a function definition

SQL WITH clause appears similar in concept to a function definition in procedural code, but it differs in an important way in older Oracle versions. The error ORA-32035: unreferenced query name defined in WITH clause informs you about this difference.

Read the Full Article →
Thumbnail image for Write Smarter Queries with the SQL WITH Clause

Write Smarter Queries with the SQL WITH Clause

SQL WITH clause, or the subquery factoring clause, makes queries more efficient and readable. When a subquery is being processed multiple times, WITH lets you factor it out, give it a name and then reference the name wherever needed in the query.

Read the Full Article →
Thumbnail image for Simple CASE vs. Searched CASE

Simple CASE vs. Searched CASE

The CASE construct in Oracle has two variants – the simple CASE and the searched CASE. Here’s a closer look to compare them in structure and functionality.

Read the Full Article →
Thumbnail image for The Difference Between DECODE and CASE

The Difference Between DECODE and CASE

Both DECODE and CASE statements in Oracle are used for IF-THEN-ELSE conditional operations, but there are distinct differences in their power and behavior.

Read the Full Article →
Thumbnail image for Selecting ODD or EVEN rows from a table

Selecting ODD or EVEN rows from a table

Question: How can I select only the even/odd rows from an Oracle table? Answer: Talking of “even or odd rows” is meaningless in Oracle until you have ordered the rows.

Read the Full Article →
Thumbnail image for LEVEL Pseudocolumn in Hierarchical Queries

LEVEL Pseudocolumn in Hierarchical Queries

LEVEL is a pseudocolumn (i.e. not a real column in the database but available in a query), which has a special function in hierarchical queries – it returns the position of any row in the hierarchy.

Read the Full Article →
Thumbnail image for Hierarchical Queries: A QuickStart Guide

Hierarchical Queries: A QuickStart Guide

A hierarchical query is one that works on data with a tree relationship. Oracle provides specialized keywords that work with hierarchical queries, such as START WITH…CONNECT BY, PRIOR and SYS_CONNECT_BY_PATH.

Read the Full Article →