Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple SQL Question

Re: Simple SQL Question

From: Juliet White <juwhite_at_au.oracle.com>
Date: Mon, 20 Mar 2000 17:22:00 +1100
Message-ID: <38D5C388.827599CC@au.oracle.com>


Hello,

For the first problem:

                select cname
                from company
                where city in (select city
                                      from company
                                      where cname = "Bank of Trade");

For the second problem:

                select city
                from company c, manages m
                where city in (select e.ename
                                      from employee e, manages m, company c
                                      where e.eid=m.eid and
                                                 e.city=c.city)
                and c.bid=m.bid;

We get a match on the employee id and the manager id so that when we match the city where the employee lives with the city that the company is located, we retrieve the manager that lives and manages in the same city.

I hope that helps you.....

Vinh Duong wrote:

> Hi,
>
> I have the following tables:
>
> Employee (eid, ename, street, city)
> Works (eid, bid, cname,salary)
> Company (bid, cname,city)
> Manages (eid, mid, bid, cname)
>
> A company, which is uniquely identified by its cname, may have branches
> (indicated by bid) in more than one city.
>
> Help me the write TWO appropriate queries that each satisfy the following
> requirements:
>
> 1- Find the names of companies that are located IN EVERY CITY in which 'Bank
> of Trade' is located.
>
> 2-Make a list of the cities which have one of its residents as a manger IN
> EVERY COMPANY located in the city.
>
> Gracias,
>
> Vinh
> Montreal


Received on Mon Mar 20 2000 - 00:22:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US