SQL Practice Logo

SQLPractice Online

Data Types & Type Conversion: Next

Module: SQL Fundamentals

Column Aliasing & Expressions

String Functions & Operations

Date & Time Functions

CASE Statements & Conditional Logic

NULL Values & IS NULL

Write a query that safely converts a staging table's string amounts to DECIMAL(10,2) using TRY_CAST

Compare FLOAT and DECIMAL results for: 0.1 + 0.2, 1/3, and 123.45 × 1.075

Fix a broken WHERE clause: WHERE YEAR(created_at) = 2024 — make it SARGable

Write a TIMESTAMPTZ query that shows an order time in New York, London, and Tokyo

Profile a query with EXPLAIN before and after fixing an implicit conversion in the predicate

Design a right-sized schema for a 100M-row clickstream table (event_type, user_id, score, ts)

Why does WHERE phone = 1234567890 kill the index on a VARCHAR phone column?

What is the difference between DECIMAL(10,2) and FLOAT for storing prices?

How does TIMESTAMPTZ differ from TIMESTAMP, and why does it matter for global apps?

When would you choose TRY_CAST over CAST?

You need to store product attributes that vary by category (clothing has size/color, electronics has RAM/storage). What type approach would you use?

PostgreSQL Documentation: Data Types — https://www.postgresql.org/docs/current/datatype.html

IEEE 754 Floating Point Standard — why FLOAT cannot represent 0.1 exactly

SQL Server TRY_CAST / TRY_CONVERT documentation

PostgreSQL JSONB indexing with GIN — https://www.postgresql.org/docs/current/gin.html