?
Solved

how to do this qustion in sql (2)

Posted on 1998-12-10
2
Medium Priority
?
176 Views
Last Modified: 2010-03-19
hi, here is another question. I am learning sql now so I have many unclear question.
say like this table:
name ticket
chris 01
chris 02
chris 03
kim 04
kim 03
Gal 03
Gal 04
Gal 05

find the person who has every ticket that Kim has.
in this case it will be: Gal
0
Comment
Question by:ny971181
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
cognition earned 200 total points
ID: 1092215
SELECT t1.name
FROM tickets t1, tickets t2
WHERE t1.ticket = t2.ticket
AND t2.name = "Kim"
AND t1.name <> "Kim"
GROUP BY t1.name
HAVING COUNT(*) >= (SELECT COUNT(*) FROM tickets WHERE name = "Kim")


0
 
LVL 1

Author Comment

by:ny971181
ID: 1092216
PERFECT, SEE I LEARNED HOW TO USE SELF JOIN!!
THANK YOU!
MAY BE YOU KNOW HOW TO DO THE OTHER ONE TOO
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question