SQL Exercises: Select specific columns from a table
6. Specific Columns of Salespeople
Write a SQL statement to display specific columns such as names and commissions for all salespeople.
Sample table: salesmansalesman_id | name | city | commission -------------+------------+----------+------------ 5001 | James Hoog | New York | 0.15 5002 | Nail Knite | Paris | 0.13 5005 | Pit Alex | London | 0.11 5006 | Mc Lyon | Paris | 0.14 5007 | Paul Adam | Rome | 0.13 5003 | Lauson Hen | San Jose | 0.12
Sample Solution:
-- This query selects specific columns 'name' and 'commission' from the 'salesman' table.
SELECT name, commission
-- Specifies the table from which to retrieve the data (in this case, 'salesman').
FROM salesman;
Output of the Query:
name commission James Hoog 0.15 Nail Knite 0.13 Pit Alex 0.11 Mc Lyon 0.14 Paul Adam 0.13 Lauson Hen 0.12
Code Explanation:
The said SQL query that selects the "name" and "commission" columns from the 'salesman' table.
The table will have columns for "name" and "commission".

Visual presentation:

Go to:
PREV : Arithmetic Expression Result.
NEXT : Custom Column Order in Orders.
Practice Online
For more Practice: Solve these Related Problems:
- Write a SQL query to display the names and cities of all customers.
- Write a SQL query to retrieve the product names and prices from the "products" table.
- Write a SQL query to list the employee IDs and departments from the "employees" table.
- Write a SQL query to show the supplier names and contact numbers from the "suppliers" table.
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.