Blog Posts - Sql Interview Questions



Difference between row_number(), rank() and dense_rank() in SQL Server, Oracle.

Though all three are ranking functions in SQL, also known as window function in Microsoft SQL Server, the difference between rank(), dense_rank(), and row_number() comes when you have ties on ranking i.e. duplicate records. For example, if you are ra...
by javarevisited on Jul 23, 2016

How to remove duplicate rows from a table in SQL

There are a couple of ways to remove duplicate rows from a table in SQL e.g. you can use a temp tables or a window function like row_number() to generate artificial ranking and remove the duplicates. By using a temp table, you can first copy all uniq...
by javarevisited on Jul 7, 2016

4 Ways to find Nth highest salary in SQL - Oracle, MSSQL and MySQL

One of the most common SQL interview questions is to find the Nth highest salary of employee, where N could be 2, 3, 4 or anything e.g. find the second highest salary in SQL. Sometimes this question is also twisted as to find the nth minimum salary i...
by javarevisited on Jan 12, 2016

SQL EXISTS Example - Customers Who Never Order LeetCode Solution

Good morning Guys, Today we will learn how to use the EXISTS clause in SQL by picking up a nice SQL exercise from LeetCode. Suppose that a website contains two tables, the Customers table and the Orders table. Write an SQL query to find all customers...
by javarevisited on Jan 3, 2016

2nd highest salary in Oracle using ROW_NUMBER and RANK in Oracle and MSSQL

This is the second article about calculating 2nd highest salary in SQL. In the first part, you have learned how to find the second highest salary in MySQL, SQL SERVER and by using ANSI SQL, which should also work in all database which confirms ANSI s...
by javarevisited on Nov 30, 2015

Which Describes the default behaviour when you create a table in SQL ?

The table is accessible to all users. Tables are created in the public Schema. Tables are created in your schema. Tables are created in the DBA schema. You must specify the schema when the table us created. ...
by Datastage on Aug 13, 2015

Which Describes the default behaviour when you create a table in SQL ?

The table is accessible to all users. Tables are created in the public Schema. Tables are created in your schema. Tables are created in the DBA schema. You must specify the schema when the table us created. ...
by Datastage on Aug 13, 2015

5 More Frequently Asked DB2 SQL Queries

I collected from my friends, for DB2 interviews these SQL queries you need to practice more times. Query#1 1) What are the different SELECT statements? A. select clause: Enumerates the column names and related constructs from clause: Describes the ta...

PL/SQL Interview Questions – Part-1

Filed under: Oracle, PL/SQL Tagged: Oracle, PL/SQL Interview Questions...

Difference between char, varchar, nchar and nvarchar data type in SQL Server database

What is difference between char and varchar in SQL, followed by nchar and nvarchar, is one of the popular SQL interview question, and surprisingly not every programmer knows this basic difference. If you go with name, which you should, than you can f...
by javarevisited on Nov 22, 2013

Difference between Clustered Index and Non Clustered Index in SQL Server - Database Interview Question

In SQL Server database there are mainly two types of  indexes, Clustered index and Non Clustered index, and difference between Clustered and Non Clustered index is very important from SQL performance perspective. It is also one of the most common SQ...
by javarevisited on Aug 5, 2013

Difference between WHERE vs HAVING clause in SQL - GROUP BY Comparison with Example

What is difference between WHERE and  HAVING clause in SQL is one of the most popular question asked on SQL and database interviews, especially to beginners. Since programming jobs, required more than one skill, it’s quite common to see couple of...
by javarevisited on Aug 1, 2013

SQL: AND Command

In SQL, we have, seen that, we can add conditions by using WHERE command, during any SELECT, UPDATE or DELETE operation. Now, what about multiple conditions? For that, SQL provides to add multiple condition by using AND command. it can be used a...
by JAVA INTERVIEW QUESTIONS on Mar 18, 2013

SQL: SELECT Command

SELECT command is use in SQL to "SELECT [some info] FROM [a location]".  Now, this is the basic structure of the SELECT query, where SELECT and FROM are 2 commands of SQL. Here, [some info] part will be the column names separated by comma (,) si...
by JAVA INTERVIEW QUESTIONS on Mar 18, 2013

SQL: OR Command

In SQL, we have seen the use of AND command, to set multiple condition when performing a database transaction. But when we use AND, that means it's a mandatory condition. The transaction will provide output, only when all the conditions will be satis...
by JAVA INTERVIEW QUESTIONS on Mar 18, 2013

SQL: WHERE Command

In SQL,when ever you want to SELECT some data, or UPDATE or DELETE some information from a Table, you needs to provide some condition, on basis of which operation will be performed. It's not necessary to SELECT, UPDATE or DELETE all data from a table...
by JAVA INTERVIEW QUESTIONS on Feb 22, 2013

SQL: What is SQL

  SQL (Structured Query Language) is a type of programming language, which uses to communicate with database. It’s also known as “sequel”. It provides some syntax which helps you to interact with a database. These syntaxes are very similar...
by JAVA INTERVIEW QUESTIONS on Feb 13, 2013


Trending Topics

Close