Sql Queries
Questions
[use NorthWind Database]
1. Select the Order Details of all the orders ordered by the Customer whose CustomerID='ANATR'
2. Select the number of Orders for the Product whose ProductID='12'
3. Select the CustomerID, who has placed the maximum number of Orders
4. Select the maximum Freight Charge for a Ship from 'Brazil'
5. Display the First Name of the Reporting Manager of the Employee whose EmployeeID='9'
6. Select the Employee who has the maximum Service Years
7. Select the distinct Countries of the Customers for which the Employee serves whose EmployeeID='5'.
8. Find the Seniormost Employee (like CEO) from the Employee Table
9. Display the OrderDetails of the Orders which are placed in the October month of 1997
10. Display the sum of the Freight Charges for each of the Employee from the Orders Table
Answers
1.Select * from [Order Details] od,Orders o where o.OrderID=od.OrderID and CustomerID='ANATR'
2.select count(ProductID) from [Order Details] od where ProductID=12
3.select customerID from orders ta group by customerid having count(CustomerID) >= ALL (select count(customerid) cou from orders group by customerid)
4.select max(Freight) from Orders where ShipCountry='Brazil'
5.select e2.firstname from employees e1,employees e2 where e2.employeeID=e1.ReportsTo and e1.EmployeeId=9
6.select firstname from employees where hiredate=(select min(hiredate) from employees)
7.select distinct(customers.country) from customers,orders,employees where customers.customerid=orders.customerid and orders.employeeid=employees.employeeid and employees.employeeid=5
8.select firstname from employees where ReportsTo is null
9.select * from [Order details],Orders where Orders.OrderId=[Order details].OrderId and Orders.OrderDate between '1997-10-01' and '1997-10-31'
10.select sum(freight) from Orders Group by employeeId order by employeeID
1 comment:
Really a good technical site,keep on writing good stuffs
dot net training in chennai
Post a Comment