Home > Database > Mysql Tutorial > SQL Basic Question for interview

SQL Basic Question for interview

Linda Hamilton
Release: 2024-12-27 07:01:10
Original
860 people have browsed it

Let's come to the point.

I have created an Awesome SQL Interview GitHub repo to prepare for interview questions and practice SQL queries. I have divided the SQL queries into three sections: Basic (L0), Intermediate (L1), and Advanced (L2). This is the solution for the basic section.


L0: Basic SQL

  • Questions related to basic SQL commands such as SELECT, INSERT, UPDATE, and DELETE.
  • Queries related to basic data manipulation and retrieval from simple tables.

Query Questions:

  1. How do you display all columns and rows from the customers table?
  2. Write a query to retrieve only the customerName and phone from the customers table.
  3. How do you list all rows where country is 'USA' in the customers table?
  4. Write a query to find all products in the products table with a buyPrice less than 50.
  5. How do you fetch all orders with a status of 'Shipped' from the orders table?
  6. Write a query to display the productName and quantityInStock for all products in the products table.
  7. How do you find the distinct country values in the customers table?
  8. Write a query to count the total number of customers in the customers table.
  9. How do you retrieve all employees whose jobTitle is 'Sales Rep'?
  10. Write a query to sort the products table by productName in ascending order.
  11. How do you fetch the customerName and city of all customers located in 'Paris'?
  12. Write a query to display the top 10 orders from the orders table based on the orderDate.
  13. How do you retrieve all offices located in the USA?
  14. Write a query to display all employees who work in the office located in 'San Francisco'.
  15. How do you calculate the total number of orders placed in the orders table?
  16. Write a query to display the productName of all products in the products table where productLine is 'Classic Cars'.
  17. How do you find the customerName of all customers whose creditLimit is greater than 50,000?
  18. Write a query to fetch all products that have a quantityInStock between 10 and 100.
  19. How do you retrieve all orders placed in the year 2003?
  20. Write a query to display the employeeNumber and firstName of employees whose last names start with 'B'.

Solution with explanation

  1. How do you display all columns and rows from the customers table?
    SQL Basic Question for interview

  2. Write a query to retrieve only the customerName and phone from the customers table.
    SQL Basic Question for interview

  3. How do you list all rows where country is 'USA' in the customers table?
    SQL Basic Question for interview

  4. Write a query to find all products in the products table with a buyPrice less than 50.
    SQL Basic Question for interview

  5. Fetch all orders with a status of 'Shipped' from the orders table.
    SQL Basic Question for interview

  6. Display the productName and quantityInStock for all products in the products table.
    SQL Basic Question for interview

  7. Find the distinct country values in the customers table.
    SQL Basic Question for interview

  8. Count the total number of customers in the customers table.
    SQL Basic Question for interview

  9. Retrieve all employees whose jobTitle is 'Sales Rep'?
    SQL Basic Question for interview

  10. Sort the products table by productName in ascending order.
    SQL Basic Question for interview

  11. Fetch the customerName and city of all customers located in 'Paris'.
    SQL Basic Question for interview

  12. Display the top 10 orders from the orders table based on the orderDate.
    SQL Basic Question for interview

  13. Retrieve all offices located in the USA.
    SQL Basic Question for interview

  14. Display all employees who work in the office located in 'San Francisco'.
    SQL Basic Question for interview

  15. Calculate the total number of orders placed in the orders table.
    SQL Basic Question for interview

  16. Display the productName of all products in the products table where productLine is 'Classic Cars'.
    SQL Basic Question for interview

  17. Find the customerName of all customers whose creditLimit is greater than 50,000.
    SQL Basic Question for interview

  18. Fetch all products that have a quantityInStock between 10 and 100.

    SQL Basic Question for interview

  19. Retrieve all orders placed in the year 2003?
    SQL Basic Question for interview

  20. Display the employeeNumber and firstName of employees whose last names start with 'B'.
    SQL Basic Question for interview


Hey, My name is Jaimin Baria AKA Cloud Boy..., If you have enjoyed and learned something useful, like this post, add a comment, and visit my Awesome SQL Interview GitHub repo.

Don't forget to give it a start ?.

Happy Coding ?‍?

The above is the detailed content of SQL Basic Question for interview. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template