John Lui
John Lui

Reputation: 1464

How do I solve this SQL Query?

Tables:

The attributes marked with P are the primary key of the table.

The above is a relational schema and I have to write the SQL syntax for the following query:

In the above statement, branch-name is not the primary key for account but is for branch. Therefore, is the above right?

Upvotes: 0

Views: 2569

Answers (1)

Alessandro Rossi
Alessandro Rossi

Reputation: 2450

This should be the right query

select *
from CUSTOMER c
where not exists (
        select BRANCH-NAME
        from BRANCH
        where BRANCH-CITY = 'Noida'
        minus
        select BRANCH-NAME
        from ACCOUNT 
            join DEPOSITOR d using (ACCOUNT-NUMBER)
        where d.CUSTOMER-NAME = c.CUSTOMER-NAME
    )

Upvotes: 2

Related Questions