Knowee
Questions
Features
Study Tools

Find Customer RefereeGiven a table customer holding customers information and the referee.idnamereferee_id1WillNULL2JaneNULL3Alex24BillNULL5Zack16Mark2Write a query to return the list of customers NOT referred by the person with id'2'. For the sample data above, the result is:nameWillJaneBillZackOptionsselect namefrom customerwhere referee_id is null or referee_id <> 2;select namecustomerwhere referee_id is null or referee_id <> 2;select referee_idfrom customerwhere referee_id is null or referee_id <> 2;select namefrom customerwhere name is null or referee_id <> 2;

Question

Find Customer RefereeGiven a table customer holding customers information and the referee.idnamereferee_id1WillNULL2JaneNULL3Alex24BillNULL5Zack16Mark2Write a query to return the list of customers NOT referred by the person with id'2'. For the sample data above, the result is:nameWillJaneBillZackOptionsselect namefrom customerwhere referee_id is null or referee_id <> 2;select namecustomerwhere referee_id is null or referee_id <> 2;select referee_idfrom customerwhere referee_id is null or referee_id <> 2;select namefrom customerwhere name is null or referee_id <> 2;

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct query to find the list of customers NOT referred by the person with id '2' is:

select name
from customer
where referee_id is null or referee_id <> 2;

This query will select the names from the customer table where the referee_id is either null (meaning the customer was not referred by anyone) or where the referee_id is not equal to 2 (meaning the customer was not referred by the person with id 2).

This problem has been solved

Similar Questions

Find the names of the customer that are not referred by the customer with id = 2.Return the result table in any order.The result format is in the following example.

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);

You have a database with a customers table. Here is a partial listing of the records:First_NameLast_NameMichelleSenseAlexisRodriguezFloraSatoYou also have a table of employees. Here is a partial listing of the records:First_NameLast_NameSamuelClementineAlexisRodriguezJabariReddyYou want to create a query that will not return “Alexis Rodriguez” as part of the results. You begin typing your query:SELECT First_Name, Last_Name FROM customers________SELECT First_Name, Last_Name FROM employeesWhat should you type in the blank space between the two queries? (Please type your answer all in upper case. Example: SELECT)

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;

You have a sales table that has a salesAmount and a customerNumber field. You need to find the You are creating a query that will join the results of two tables. You begin typing the query:SELECT customers.firstName, customers.lastName, orders.orderDateFROM customers ______ JOIN ordersON customers.customerNumber = orders.customerNumberYou want to see all the rows from the customers table, even if they don’t have a corresponding record in the orders table.What should you type in the blank space? (Please type your answer all in upper case. Example: SELECT or UNION ALL)

1/1

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.