Interview Questions and Answers for 'Sql' - 49 question(s) found - Order By Rating Q1. Write SQL query to join 2 tables ? SQL
Ans. Select * from table1 join Select * from table2 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database Asked in 1 Companies Q2. Sort an Employee Object based on Name or Age Database
Ans. Use Comparable or Comparator interface Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql query Asked in 1 Companies Q3. What is the minimum number of tables required to perform a SQL join? Database
Ans. 1 , We can do self join
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql join Asked in 1 Companies Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  aws dynamodb  aws nosql database  amazon cloud nosql database Q5. create an SQL query across multiple tables involving outer joins Database
Ans. Select * from table1 t1Left outer join table2 t2 on t1.tid = t2.id Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql query  database  outer joins Asked in 2 Companies Ans. Fast reads
Much more reads than writes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  aws dynamodb  aws nosql database  amazon cloud nosql database Q7. What is the use of sql dialect ? Hibernate
Ans. Dialect means "the variant of a language".
Similarly in case of SQL Dialect we specify what dialect of SQL to be generated keeping in mind of underlying database. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql dialect  hibernate   hibernate Asked in 2 Companies Q8. Given an Employee Table with Salary Column, Find 2nd and 5th highest salary in a particular department. SQL
Ans. Select salary from (select salary from employee where department = order by salary desc limit 5) emp order by salary limit 1 AND Select salary from (select salary from employee where department = order by salary desc limit 2) emp2 order by salary limit 1 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql  database   find 2nd highest salary sql database Asked in 1 Companies Q9. Write SQL to get all members and the count of books they have checked out , even the ones that haven't checked out anything. SQL
This question was recently asked at 'Canopy Tax'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql Asked in 1 Companies Q10. Difference between Left and Inner Join ? SQL
This question was recently asked at 'Canopy Tax,Cogent Infotech Corp'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql Asked in 2 Companies Q11. What are different types of No Sql Databases ? NoSql
Ans. graph based
column based
document based Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q12. What are different in memory data structures that are used in No Sql Database ? NoSql Database
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Ans. Oracle having following types of joins these are also called 8i joins. There are:
1. Equi (or) Inner join
2. Non Equi join
3.Self join
4.Outer join
Oracle also support the 9i (or) ANSI standard joins.There are:
1.Inner join
2.Left outer join
3.Right outer join
4.Full outer join
5.Natural join Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql joins  sql Asked in 2 Companies Ans. It returns all the rows form the left table and matches the rows in both tables. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database   database joins   left outer join  sql Asked in 2 Companies Q15. Is there any schema in mongo DB ? MongoDB
Ans. There is schema in mongo-db but the schema need not to be defined before creating collection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  mongodb  nosql  bigdata Asked in 1 Companies Q16. Write an SQL to get Employees who are also Managers SQL
Ans. SELECT A.NAME FROM EMPLOYEE A, EMPLOYEE B WHERE A.ID = B.MANAGER_ID Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q17. Write a SQL to display all duplicate names from Employee Table SQL
Ans. SELECT * FROM EMPLOYEE A WHERE A.ROW_ID IN (SELECT MAX(ROW_ID) FROM EMPLOYEE b WHERE A.NAME = B.NAME ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q18. Write a SQL to find max salary by Dept SQL
Ans. SELECT MAX(SALARY),DEPT FROM EMPLOYEE GROUP BY DEPT Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q19. Write a SQL to find 2nd Max value in a Table. Database
Ans. SELECT MIN(FIELD) FROM (SELECT TOP 2 FIELD FROM TABLE ORDER BY FIELD DESC)
or
SELECT MAX(FIELD) FROM TABLE WHERE FIELD NOT IN (SELECT MAX(FIELD) FROM TABLE) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql Q20. Which is the best NoSql Database for Performance ? NoSql
Ans. Possible Answer - doument base - monogodb Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Nosql Database Q21. Which of the following databases - Cassandra / Oracle - provides more flexibility about querying the database ? Database
Ans. Oracle as it is not modeled for a particular query or set of queries. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Cassandra  Nosql database  nosql vs relational database Q22. How different is the Search algorithm when we query Cassandra Tables and When we query Oracle Tables ? Cassandra
Ans. Relational Database uses linear search if we don't query using indices. Performance for linear search is O(n). If indices have been used , relational database uses binary search. Performance for binary search is O(Log n).
Casandra uses hash search. Performance for Hash Search is O(1). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cassandra vs oracle  nosql vs relational  search algorithm Q23. Write a SQL to remove records with a duplicate field in a Table ? Database
This question was recently asked at 'Sofi'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql Asked in 1 Companies Q24. If Table A has 0 records and Table B has 50 records , how many records will the equi join of Table generate ? SQL
Ans. 0 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   equi join Q25. If Table A has 100 records and Table B has 50 records , how many records will the right join of Table A with Table B generate ? SQL
Ans. 50 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   right join Q26. If Table A has 100 records and Table B has 50 records , how many records will the left join of Table A with Table B generate ? SQL
Ans. 100 records Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql  sql joins   left join Q27. If Table A has 100 records and Table B has 50 records , how many records will the equi join of Table generate ? SQL
Ans. It depends on the join condition. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  equi join  sql join  database  sql Q28. What do you make out of this error
org.hibernate.exception.ConstraintViolationException: could not insert: [<Entity>]
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (<Constraint Name>) violated
and how would you go about debugging it ? Database
Ans. Application is unable to insert a record as it violates a unique constraint.
The exception states the constraint and Table can be located by the Entity mapping. So I will go to the DB and will first check to which all columns the unique constraint applies. And then I will go and check the code and logs to see how come the duplicate column values were attempted to be inserted when they were not supposed to be. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ConstraintViolationException  SQLIntegrityConstraintViolationExceptionFrequently asked in Cognizant ( Based on 2 feedback ) Q29. What are Inner , Outer , Left and Right Joins in SQL ? Database
Ans. Inner join is the intersection of two tables on the condition defined by the where clause i.e will get records from both tables matched by a column.
Outer join is the union of two tables i.e will get all records from both tables and will put null in the columns where related records are not present.
Left Outer join is the left union of two tables i.e all records from the table on the left and values from the right table for related records else null for the columns from right table.
Right Outer join is the right union of two tables i.e all records from the table on the right and values from the left table for related records else null for the columns from left table. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql  inner join  outer join  right join  left join Asked in 24 Companies basic   frequent Q30. With a Table employee having columns Id,Name,ManagerEmployeeId, Write a SQL to find the Manager with maximum number of employees ? Database
Ans. Select Name from EMPLOYEE where ID in (Select ManagerEmployeeId from EMPLOYEE
Group By ManagerEmployeeId
order by count(Id)
LIMIT 1) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  sql Asked in 1 Companies