Which of the following is the correct query to find all the orders against the employee who works for the customer whose id is 1234 ?The required tables are :Employee(eid, name, city) and orders (ord_no, purch_amt, ord_date, customer_id, eid)OPTIONS:-ASelect * from orders where eid (select DISTINCT eid from orders where customer_id=1234) order by eid.BSelect * from orders where eid=(select DISTINCT eid from orders where customer_id=1234);CSelect * from orders where eid = (select eid from orders) where customer_id=1234;DSelect * from salesman where eid =(select DISTINCT eid from orders) where customer_id=1234;
Question
Which of the following is the correct query to find all the orders against the employee who works for the customer whose id is 1234 ?The required tables are :Employee(eid, name, city) and orders (ord_no, purch_amt, ord_date, customer_id, eid)OPTIONS:-ASelect * from orders where eid (select DISTINCT eid from orders where customer_id=1234) order by eid.BSelect * from orders where eid=(select DISTINCT eid from orders where customer_id=1234);CSelect * from orders where eid = (select eid from orders) where customer_id=1234;DSelect * from salesman where eid =(select DISTINCT eid from orders) where customer_id=1234;
Solution
The correct query is option B.
Here's why:
Option B is the correct query because it selects all records from the 'orders' table where the 'eid' (employee id) is equal to the distinct 'eid' from the 'orders' table where the 'customer_id' is 1234. This will return all orders made by the employee who works for the customer with the id 1234.
Option A is incorrect because it lacks the equals sign (=) after 'where eid', which is necessary for the subquery to work.
Option C is incorrect because it has two 'where' clauses in a row, which is not valid SQL syntax.
Option D is incorrect because it's selecting from the 'salesman' table, which is not mentioned in the question. The question only mentions the 'Employee' and 'orders' tables.
Similar Questions
Which of the following query is correct to fetch all the employee details from the employee table
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.IdName1Joe2Henry3Sam4MaxTable: Orders.IdCustomerId1321Using the above tables as example, return the following:CustomersHenryMaxOptionsselect Name as Customers from Customers not in ( select CustomerId from Orders);select Name from Customers where Id in ( select CustomerId from Orders);select Name as Customers from Customers where Id not in ( Orders);select Name as Customers from Customers where Id not in ( select CustomerId from Orders);
Which of the following query is correct to fetch all the employee details from the employee tableselect * from employee;extract name from employee;
For the following tables:Customers (CustomerID, CustomerName, PhoneNumber, Address)Orders (OrderID, OrderDate, CustomerID)To return the CustomerName and OrderDate that the result must include the customers who have not placed any orders.Which Transact-SQL query should you use?SELECT CustomerName, OrderDateFROM Customers JOIN Orders ON Customers.CustomerID = Orders.CustomerID;SELECT CustomerName, OrderDateFROM Customers RIGHT OUTER JOIN OrdersON Customers.CustomerID = Orders.CustomerID;SELECT CustomerName, OrderDateFROM Customers LEFT OUTER JOIN OrdersON Customers.CustomerID = Orders.CustomerID;SELECT CustomerName, OrderDateFROM Customers CROSS JOIN OrdersON Customers.CustomerID = Orders.CustomerID;
employee_id Name Salary1001 Annie 60001009 Ross 45001018 Zeith 7000above are the Employee table details.select employee_id from employee order by employee_id desc;Which of the following output will be true?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.