DBMS 面试题与答案
Test your skills through the online practice test: DBMS Quiz Online Practice Test
相关差异对比
问题 16. What is order by clause in DMBS?
ORDER BY clause helps to sort the data in either ascending order to descending order.
Ascending order sort query
SELECT name,age FROM pcdsEmployee ORDER BY age ASC
Descending order sort query
SELECT name FROM pcdsEmployee ORDER BY age DESC
这有帮助吗?
添加评论
查看评论
问题 17. What is the SQL " IN " clause?
SQL IN operator is used to see if the value exists in a group of values. For instance the below
SQL checks if the Name is either 'David' or 'Craig' SELECT * FROM wbEmployee WHERE name IN ('David','Craig') Also you can specify a not clause with the same. SELECT * FROM wbEmployee WHERE age NOT IN (30,25)
这有帮助吗?
添加评论
查看评论
问题 18. Can you explain the between clause in DBMS?
Below SQL selects employees born between '01/01/1995' AND '01/01/1978' as per mysql
SELECT * FROM wbEmployee WHERE DOB BETWEEN '1995-01-01' AND '2011-09-28'
这有帮助吗?
添加评论
查看评论
问题 19. We have an employee salary table how do we find the second highest from it?
Below Sql Query find the second highest salary:
SELECT * FROM wbEmployeeSalary a WHERE (2=(SELECT COUNT(DISTINCT(b.salary)) FROM wbEmployeeSalary b WHERE b.salary>=a.salary))
这有帮助吗?
添加评论
查看评论
问题 20. What are different types of joins in SQL?
INNER JOIN
Inner join shows matches only when they exist in both tables. Example in the below SQL there are two tables Customers and Orders and the inner join in made on Customers. Customerid and Orders.Customerid. So this SQL will only give you result with customers who have orders. If the customer does not have order it will not display that record.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON Customers.CustomerID=Orders.CustomerID
LEFT OUTER JOIN
Left join will display all records in left table of the SQL statement. In SQL below customers with or without orders will be displayed. Order data for customers without orders appears as NULL values. For example, you want to determine the amount ordered by each customer and you need to see who has not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT OUTER JOIN (Is covered in the next section) if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID
RIGHT OUTER JOIN
Right join will display all records in right table of the SQL statement. In SQL below all orders with or without matching customer records will be displayed. Customer data for orders without customers appears as NULL values. For example, you want to determine if there are any orders in the data with undefined CustomerID values (say, after a conversion or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID
这有帮助吗?
添加评论
查看评论
用户评价最有帮助的内容:
- What is database or database management systems (DBMS)?
- What is SQL?
- What's the difference between file and database? Can files qualify as a database?
- What are E-R diagrams?
- Whats difference between DBMS and RDBMS?