Solved

how to do this qustion in sql (2)

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel conversion issue with Sql server 14 50
SQL Login 17 40
MSSQL: Replace text (typo) 7 33
Sql Query Datatype 2 19
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

896 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