book-annotations

SQL Cookbook Favorites

SQL Cook Book Notes: #

Chapter 1: Retrieving Records #

For initializing the project run the following command:

psql -U postgres -h localhost -p 5432 -d postgres -f init_setup.sql

1.6 Referencing and Aliased Column in the WHERE Clause #

This is a interesting example because referencing aliased columns will fail unless you wrap it around another query:

select *
  from (
    select sal as salary, comm as commission
    from emp
  ) x
  where salary < 5000

This works because the order of clauses is the next one:

...

Made with using Hugo | © 2025 Alegarciy