Monday, February 11, 2019

SQL question challenge (Customer with no orders)

SQL Challenge
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: Customer.

| Id | Name  |   
| 1  | Joe   |
| 2  | Henry |
| 3  | Sam   |
| 4  | Max   |

Using the above tables as example, return the following:

| Customers |
| Henry     |
| Max       |


create table customer (id int,name varchar(100))
insert into customer values(1,'Joe');
insert into customer values(2,'Henry');
insert into customer values(3,'Sam');
insert into customer values(4,'Max');

create table orders(id int,customer_id int);
insert into orders values(1,3);
insert into orders values(3,1);


select from customer cust
 left join orders ord on
 where is null;

1 comment:

  1. any case, it additionally implies more open doors for the business to demonstrate significant elements like shopper conduct, taking into account increasingly exact perspectives on circumstances and dangers. ExcelR Data Science Courses