Re: Matching on more than one item?
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 06/09/04
- Next message: Tibor Karaszi: "Re: yukon beta"
- Previous message: Tibor Karaszi: "Re: Last executed date"
- Maybe in reply to: Tom Moreau: "Re: Matching on more than one item?"
- Next in thread: David Portas: "Re: Matching on more than one item?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Jun 2004 20:20:06 +0100
Assuming the primary key is (customer_no, query_no, date_logged, code):
SELECT customer_no, query_no, date_logged
FROM Product
WHERE code IN (31,32,44)
GROUP BY customer_no, query_no, date_logged
HAVING COUNT(*)=3
If the key is something different:
SELECT customer_no, query_no, date_logged
FROM Product
WHERE code IN (31,32,44)
GROUP BY customer_no, query_no, date_logged
HAVING COUNT(DISTINCT code)=3
Please include DDL with future posts so that we don't have to guess at keys,
etc.
-- David Portas SQL Server MVP --
- Next message: Tibor Karaszi: "Re: yukon beta"
- Previous message: Tibor Karaszi: "Re: Last executed date"
- Maybe in reply to: Tom Moreau: "Re: Matching on more than one item?"
- Next in thread: David Portas: "Re: Matching on more than one item?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|