# Category: SQL INTERVIEW QUESTIONS

Lets take a look at differences between INTERVAL and ADD_MONTHS() in Teradata. This post mainly focused on where to use ADD_MONTHS() over INTERVAL function in Teradata. INTERVAL is a …

## PIVOT OCCUPATIONS TABLE DATA QUERY

PROBLEM STATEMENT: Pivot the ‘Occupation’ column in OCCUPATIONS table so that each ‘Name’ is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, …

## TOP EARNERS FROM EMPLOYEE SALARY TABLE – QUERY WITH SOLUTION

PROBLEM STATEMENT: We define an employee’s total earnings to be their monthly salary*months worked, and the maximum total earnings to be the maximum total earnings for any employee in …

## BINARY TREE NODES QUESTION AND SOLUTION WITH QUERY

PROBLEM STATEMENT: You are given a table, BTREE, containing two columns: Value and Parent, where ‘Value’ represents the value of a node in Binary Tree, and ‘Parent’ is the …

## NEW COMPANY HIERARCHIES SQL QUERY

PROBLEM STATEMENT: one of the conglomerate corporations just acquired some new companies. Each of the companies follows this hierarchy. Given the table schemas below, write a query to print …

## FIND THE CANCELLATION RATE USING TRIPS AND USERS TABLES

PROBLEM STATEMENT: The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users …

## FINDING TOP 3 SALARIES SQL QUERY

The Employee table holds all employees. Every employee has an Id, and there is also a column for the Department Id. ID Name Salary DepartmentId 1 Joe 85000 1 …

## Difference Between RANK() and DENSE_RANK() in SQL with an Example

There is a small difference between RANK() and DENSE_RANK() analytic functions. Lets take an example to illustrate this. 1. select ename,deptno,sal,RANK() OVER  (PARTITION BY deptno ORDER BY SAL) from …