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.
Though CASE behaves like IF-THEN-ELSE, it differs in one important way – CASE requires a defined leg for each scenario. If an undefined leg is chosen, the exception ORA-06592: CASE not found while executing CASE statement is raised.
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.
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.
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.
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.
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.
When you are starting out preparing for Oracle interviews, you might imagine that learning answers to lists of interview questions is the way to get a decent job. This article shows you why this is the wrong way to go about it, and suggests what to do instead.