Gomaa Intelligence.Data Hub
عربي

Foundations › SQL › SQL Basics

🔎 SQL Basics

NULL, Data Types and Text Functions

Lesson 8 / 14· 9 min

NULL means the value is unknown, not zero and not an empty string. That changes how comparisons and arithmetic behave.

▶ Try it yourself

Any arithmetic with NULL gives NULL, and NULL = NULL is not TRUE. Test emptiness with IS NULL. Open in SQL Lab

▶ Try it yourself

Customers without an email. Open in SQL Lab

▶ Try it yourself

COALESCE returns the first non-NULL value. Open in SQL Lab

Text functions and casting

▶ Try it yourself

|| concatenates text in SQLite and PostgreSQL. Open in SQL Lab

▶ Try it yourself

CAST converts the type. Open in SQL Lab

For advanced readers Three-valued logic and types

SQL has three truth values: TRUE, FALSE and UNKNOWN, and WHERE keeps only TRUE. SQLite is flexible about types while PostgreSQL and SQL Server are strict; prefer explicit CAST. Concatenation: || in SQLite, PostgreSQL and Oracle, CONCAT in MySQL, + or CONCAT in SQL Server.

Exercise 1 — Show the name and city of customers who have no email.

Exercise 2 — Show one column label formatted as: name then the city in uppercase in parentheses, e.g. Ahmed Ali (CAIRO).

Summary
  • NULL = unknown value; test with IS NULL.
  • COALESCE substitutes empty values.
  • CAST converts types and || joins text.

Want an expert to do it for you?

Gomaa Intelligence turns your data into clear reports and decisions. Tell us your problem and we will reply.

Get your data analyzed by an expert ↗