LIST OF IMPORTANT SQL QUERIES FOR INTERVIEW

Rohit Ghumare
12 min readJul 25, 2019

1. Query for Retrieving Tables

This query can be run to retrieve the list of tables present in a database where the database is “My_Schema”.

SELECT * FROM My_Schema.Tables;

2. Query for Selecting Columns from a Table

This is perhaps the most widely used of SQL queries examples. In the example below, we are extracting the “Student_ID” column or attribute from the table “STUDENT”.

SELECT Student_ID FROM STUDENT;

If you want to display all the attributes from a particular table, this is the right query to use:

SELECT * FROM STUDENT;

3. Query for Outputting Data Using a Constraint

This SQL query retrieves the specified attributes from the table on the constraint Employee ID =0000

SELECT EMP_ID, NAME FROM EMPLOYEE_TBL WHERE EMP_ID = '0000';

4. Query for Outputting Sorted Data Using ‘Order By’

This query orders the results with respect to the attribute which is referenced to using “Order By” — so for example, if that attribute is an integer data type, then the result would either be…

--

--