SQL Exercises 1— Retrieve Data from Tables

1. Display a string “This is aadata’s SQL Exercise”.

2. Display three numbers in three columns.

3. Display the sum of two numbers 10 and 15.

4. Display the result of an arithmetic expression.

1. Display all the information of all salesmen.

2. Display specific columns like name and commission for all the salesmen

3. Find the salespeople who lives in the City of ‘Paris’. Return salesperson’s name, city.

1. Display the columns in a specific order like order date, salesman id, order number and purchase amount from for all the orders.

2. Find the unique salespeople ID. Return salesman_id.

3. Find the orders, which are delivered by a salesperson of ID. 5001. Return ord_no, ord_date, purch_amt.

1. Find those customers whose grade is 200. Return customer_id, cust_name, city, grade, salesman_id.

1. Find the Nobel Prize winner(s) in the year 1970. Return year, subject and winner.

2. Find the Nobel Prize winner in ‘Literature’ in the year 1971. Return winner.

3. Find the Nobel Prize winner ‘Dennis Gabor’. Return year, subject.

4. Find the Nobel Prize winners in ‘Physics’ since the year 1950. Return winner.

5. Find the Nobel Prize winners in ‘Chemistry’ between the years 1965 to 1975. Begin and end values are included. Return year, subject, winner, and country

6. Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin.

7. Find the details of the winners whose first name matches with the string ‘Louis’. Return year, subject, winner, country, and category.

8. Combine the winners in Physics, 1970 and in Economics, 1971. Return year, subject, winner, country, and category.

9. Find the Nobel Prize winners in 1970 excluding the subjects Physiology and Economics. Return year, subject, winner, country, and category.

10. Combine the winners in ‘Physiology’ before 1971 and winners in ‘Peace’ on or after 1974. Return year, subject, winner, country, and category.

11. Find the details of the Nobel Prize winner ‘Johannes Georg Bednorz’. Return year, subject, winner, country, and category.

12. Find the Nobel Prize winners for the subject not started with the letter ‘P’. Return year, subject, winner, country, and category. Order the result by year, descending.

13. Find the details of 1970 Nobel Prize winners. Order the result by subject, ascending except ‘Chemistry’ and ‘Economics’ which will come at the end of result set. Return year, subject, winner, country, and category.

1. Select a range of products whose price is in the range Rs.200 to Rs.600. Begin and end values are included. Return pro_id, pro_name, pro_price, and pro_com.

2. Calculate the average price for manufacturer code equal to 16. Return avg.

3. Display the pro_name as ‘Item Name’ and pro_price as ‘Price in Rs.’

4. Find the items whose prices are higher than or equal to $250. Order the result by product price in descending, then product name in ascending. Return pro_name and pro_price.

5. Calculate average price of the items of each company. Return average price and company code.

6. Find the cheapest item(s). Return pro_name and, pro_price.

1. Find unique last name of all employees. Return emp_lname.

2. Find the details of employees whose last name is ‘Snares’. Return emp_idno, emp_fname, emp_lname, and emp_dept.

3. Find the details of the employees who work in the department 57. Return emp_idno, emp_fname, emp_lname and emp_dept.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store