45.8k views
2 votes
Structure of the CUSTOMERS table

Which of the following queries will display the first and last name of the individual who referred another customer, along with the customer# of the referred customer?

a) SELECT firstname, lastname, referred_customer#
FROM customers
WHERE referred_customer# IS NOT NULL;

b) SELECT firstname, lastname, customer#
FROM customers
WHERE referred_customer# IS NOT NULL;

c) SELECT firstname, lastname, customer#
FROM customers
WHERE referred_customer# IS NULL;

d) SELECT firstname, lastname, referred_customer#
FROM customers
WHERE referred_customer# IS NOT NULL;

1 Answer

2 votes

Final answer:

The correct SQL query is Option B, which selects firstname, lastname, and customer# for the entries where referred_customer# is not null, showing the referrer's names alongside their referred customer's ID.

Step-by-step explanation:

The question is about writing SQL queries to display certain information from a customers database table. The correct query to display the firstname and lastname of the individual who referred another customer, along with the customer# of the referred customer is Option B:

SELECT firstname, lastname, customer# FROM customers WHERE referred_customer# IS NOT NULL;

This query selects the firstname, lastname, and customer number from the customers table where the referred_customer# field is not null, indicating that the listed customers were referred by someone.

User Milt
by
7.5k points