w3resource

PostgreSQL Basic SELECT Statement: Select first ten records from a table


18. Write a query to select first ten records from a table.

Sample Solution:

Code:

SELECT employee_id, first_name 
FROM employees  LIMIT 10;

Sample table: employees


Output:

pg_exercises=# SELECT employee_id, first_name
pg_exercises-# FROM employees  LIMIT 10;
 employee_id | first_name
-------------+------------
         100 | Steven
         101 | Neena
         102 | Lex
         103 | Alexander
         104 | Bruce
         105 | David
         106 | Valli
         107 | Diana
         108 | Nancy
         109 | Daniel
(10 rows)

Practice Online



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query to check whether the first_name column of the employees table containing any number.
Next: Write a query to get a monthly salary (rounded up to 2 decimal places) of each employee.

What is the difficulty level of this exercise?



Share this Tutorial / Exercise on : Facebook and Twitter