SQL Assessment PDF
SQL Assessment PDF
https://ksrconsultantservices.com/
1. Given a table SELLERS with 3 column SELLER_ID, COUNTRY and JOINING_DATE, write a query to identify number of
sellers per country and order it in descending order of no. of sellers
2. For the table in question 1 write a query to extract all sellers who joined on a Monday.
3. Given a table EMPLOYEE with two columns EMP_ID and SALARY, how can we extract alternate rows from a table?
4. Given a table EMPLOYEE with two columns EMP_ID and SALARY, extract the employees with the 3rd highest salary.
If there are 10 records in the EMP table and 5 records in the DEPT table, how many rows will be displayed in the result of the
following SQL query:
SELECT * FROM EMP, DEPT
7. What is the difference between Having and Where clause?
8. Consider a table EMPLOYEE with columns EMP_ID and SALARY with unknown number of records. Write a query to
extract top 25% of the records based on salary?
9. Consider a table EMPLOYEE with columns EMP_ID, DEPT_NO and SALARY. Write a query to extract all employees who
have salaries higher than the avg. of their department.
10. Consider a table EMPLOYEE with columns EMP_ID and SALARY. Write a select query to output a rank against each
record. The rank must be based on the salary(rank 1 for the highest salary)
11. Given two table SELLER(Seller_ID, Country_code) Country (Country_code , Country_name), write a query that outputs
Seller_ID,
Country_Name. For country_codes that do not exist in Country table the output must print “NA”.
12. For the tables in question 11, write a query to extract seller_id s that do not have a matching country_code in country
table.
13. Consider a table Sellers with columns (Seller_ID, Country, Month, Sales), write a query to extract top 10 sellers by sales for
each country.
14. If the table in question 13 has data for first 6 months in year 2015 for each seller, write a query to extract data in the
following format
https://ksrconsultantservices.com/
16. Write a query to calculate time difference (in days) between current and previous order of each customer for every row?
What is the avg time difference between two orders for every customer?
17. Write a query to populate number of orders in the same month as a separate column in each row of the input table?
18. Perform a join between the two tables to map country to each URL in table 1
URL Suffix Country
WWW.ksrconsultantservices.com .com United States
www.elezemns.ca .uk United Kingdom
www.elezemns.uk .in India
www.elezemn s.in .ca Canada
19. Given tables as below, write SQL queries to return results as requested.
https://ksrconsultantservices.com/
A. Combines the output from no more than two queries and must include the same number of columns.
B. Combines the output from no more than two queries and does not include the same number of columns.
C. Combines the output from multiple queries and must include the same number of columns.
D. Combines the output from multiple queries and does not include the same number of columns.
A. Uses the result of an inner query to determine the processing of an outer query.
B. Uses the result of an outer query to determine the processing of an inner query.
C. Uses the result of an inner query to determine the processing of an inner query.
D. Uses the result of an outer query to determine the processing of an outer query.
25. What is returned by INSTR(‘Elezemns India, ‘I’)?
A. 8 B. 10
C. Elezemns D. India
26. Q 8 - Which of the following code will remove all the rows from the table LOCATIONS?
MOD(1000,30)?
A. 33 B. 30
C. 3 D. 10
https://ksrconsultantservices.com/
28. Which of the following query would display all the students where the second letter in the first name is ‘i’?