Data Science & ML

SQL Basics

SELECT, WHERE, ORDER BY, GROUP BY, HAVING, aggregations, aliases, simple subqueries

20 interview questionsยท
Junior
1

Which SQL statement is used to retrieve data from a table?

Answer

The SELECT statement is the fundamental command for reading data from a relational database. It allows specifying which columns to retrieve and from which table. It is the first statement every developer learns in SQL as it forms the basis of all read queries.

2

How to select all columns from a table named 'users'?

Answer

The asterisk character (*) is a shortcut meaning all columns. The syntax SELECT * FROM users returns every column from the table. While convenient for exploration, explicitly naming columns is recommended in production for performance and clarity reasons.

3

Which clause is used to filter rows returned by a SELECT query?

Answer

The WHERE clause allows specifying conditions that rows must satisfy to be included in the result. It applies before any aggregation and accepts comparison operators (=, <, >, !=), logical operators (AND, OR, NOT), and special predicates (LIKE, IN, BETWEEN).

4

Which operator is used to search for a pattern in a text column?

5

How to sort query results in ascending order on a column?

+17 interview questions

Master Data Science & ML for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free