LLearningPath
Executing queries using Databricks SQL and SQL Warehouses

20% domain · module 4

Filtering, sorting, CTAS, managed vs external, federation

Starts at 44:21 in this video — SQL Warehouse full course — query parameters (44:21)

WHERE vs HAVING

WHERE filters rows before aggregation. HAVING filters groups. Top-N per group needs ROW_NUMBER() (or QUALIFY), not a global LIMIT.

CREATE TABLE choices

  • Empty table that replaces if it exists while keeping privileges and history: CREATE OR REPLACE TABLE ...
  • CREATE TABLE IF NOT EXISTS will not replace an existing table
  • DROP then CREATE can lose privileges/history the replace path is designed to keep
  • CREATE EXTERNAL TABLE is a different storage contract, not a synonym for replace

Unified datasets

You can CREATE TABLE AS SELECT joining CSV/Parquet/Delta sources (via volumes, read_files, or existing tables) into one Delta table in Unity Catalog.

Query federation

Join a Delta table to a federated source (foreign catalog / connection to another database) for cross-system analytics. Names still look like UC three-level names; performance depends on pushdown. Do not assume federated Oracle behaves like local Delta for every optimization.

Create tables · Query federation