Jump to content
besty

Oracle SQL Queries

Recommended Posts

besty

Olá a todos.

Estou a tentar resolver uns exercícios, mas não me estou a conseguir desenvencilhar de um.

As tabelas são as seguintes:

S(S#,SNAME,STATUS,CITY) (seller)

J(J#,JNAME,CITY) (jobs)

P(P#,PNAME,COLOR,WEIGHT) (parts)

SPJ(S#,J#,P#,QTY) (deal)

A questão é: Find the names of the parts that have been sold by at least 2 different sellers.

Fiz este código, mas dá-me ideia que não é o certo:

SELECT DISTINCT P.PNAME
FROM SPJ C,P,S
WHERE C.P#=P.P# AND C.S#!=S.S#

Share this post


Link to post
Share on other sites
Rui Carlos

Penso que precisas de fazer um GROUP BY e um COUNT aos sellers (atenção para não contar repetidos).

Depois é só filtrar os que deram mais do que um seller.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.