Solved

how to do this qustion in sql (2)

Posted on 1998-12-10
2
171 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CDC and AOG on MS SQL 2012 13 25
sql server query 12 26
In sql, how to roll up multiple rows to only one row. 4 39
SQL 2008 R2 problem with DB 9 16
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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

828 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