1. Write a SQL query to find the second highest salary from the "employees" table.
2. Create a function that takes a table name and returns the number of rows in that table.
3. Write a query to retrieve the top 5 products with the highest sales amounts from the "sales" table, ordered by sales amount.
4. Create a SQL function that accepts a date range and returns the count of orders placed in that date range from the "orders" table.
5. Write a query to find all employees who have the same job title but different departments from the "employees" table.
6. Write a SQL script to create a materialized view that aggregates total sales per product category from the "sales" and "products" tables.
7. Create a trigger that automatically updates a "last_modified" timestamp in a "products" table whenever a row is updated.
8. Write a query that identifies customers who have never placed an order by leveraging a "customers" table and an "orders" table.
9. Create an index on the "email" column of a "users" table to improve lookup performance. Provide the SQL syntax.
10. Write a query that returns the count of distinct users who logged in each month for the last year from the "logins" table.
Reveal all the approved answers to the questions above and explore all the types of Postgres questions and answers.
Explore NowShare on: