Interview Q&A / SQL & DBMS

INTERVIEW Q&A · 69 QUESTIONS

SQL & DBMS interview questions

Joins, keys, normalisation, indexes and transactions for placement and backend interviews.

  1. In what order does SQL actually execute the clauses of a SELECT query?

    The logical order is FROM and JOINs, WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, then LIMIT. It differs from the written order, which is why a SELECT alias works in ORDER BY but not in WHERE.

    BeginnerQuick answer1 min read
  2. What does SELECT DISTINCT do when you list more than one column?

    DISTINCT removes duplicate rows, not duplicate values in one column. Two rows are duplicates only if every selected column is equal, and NULLs are treated as equal to each other.

    BeginnerQuick answer1 min read