Solved

how to do this qustion in sql (2)

Posted on 1998-12-10
2
159 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
2 Comments
 
LVL 3

Accepted Solution

by:
cognition earned 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now