超級SQL STATEMENT問題(請求天才)....

來源: 2010-02-10 19:01:19 [舊帖] [給我悄悄話] 本文已被閱讀:

超級SQL STATEMENT問題(請求天才)

NOTE: please solve problem using plain SQL only, not a PL/SQL program

You have SQL table "table" with two columns: "name" and "gadget".
Both columns are text strings.

name | gadget
--------+-------------
mike | computer
mike | computer
mike | keyboard
mike | mouse
steve | computer
steve | phone
anton | computer
anton | keyboard
anton | mouse
anton | TV
alex | TV
alex | mouse
alex | phone
alex | computer


Person's name is given as the input argument.
Please write SQL statement which returns names of persons having unique set of gadgets which is equivalent or wider/bigger than the set of gadgets of given person.

Examples:

input: mike
output: anton
Mike has (computer, keyboard, mouse).
Anton has more gadgets (computer, keyboard, mouse) + TV.

input: steve
output: alex
Steve has (phone, computer).
Alex has (phone, computer) + TV + mouse.
Mike, Anton aren't printed - they do not have phone.

input: alex
output: