Retrieve data from tables
- Write a SQL statement to display all the information of all salesmen.
SELECT * FROM salesman;
- Write a SQL statement to display a string “This is SQL Exercise, Practice and Solution”.
SELECT 'This is SQL Exercise, Practice and Solution;'
- Write a query to display three numbers in three columns.
SELECT 2, 3, 4;
- Write a query to display the sum of two numbers 10 and 15 from RDMS sever.
SELECT 10+15;
- Write a query to display the result of an arithmetic expression.
SELECT 2*3;
- Write a SQL statement to display specific columns like name and commission for all the salesmen.
SELECT name, commission
FROM salesman;
- Write a query to display the columns in a specific order like order date, salesman id, order number and purchase amount from for all the orders.
SELECT ord_date, salesman_id, ord_no, purch_amt
FROM orders;
- Write a query which will retrieve the value of salesman id of all salesmen, getting orders from the customers in orders table without any repeats.
SELECT DISTINCT salesman_id
FROM orders;
- Write a SQL statement to display names and city of salesman, who belongs to the city of Paris.
SELECT name, city
FROM salesman
WHERE city='Paris';
- Write a SQL statement to display all the information for those customers with a grade of 200.
SELECT *
FROM