Re: How to get distinct... under certain conditions
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 06/15/04
- Next message: Raghav Mittal: "parameters in where clause"
- Previous message: Anthony Faull: "Re: what word will stop everything after it in a SQL script?"
- In reply to: dgk: "How to get distinct... under certain conditions"
- Next in thread: dgk: "Re: How to get distinct... under certain conditions"
- Reply: dgk: "Re: How to get distinct... under certain conditions"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Jun 2004 09:28:42 +0200
On Mon, 14 Jun 2004 23:46:42 GMT, dgk wrote:
>I would like to retrieve distinct customer IDs where the customer has
>at least one record that meets the condition of FieldX <> "Y". I have
>this: "SELECT distinct CustID FROM Orders order by CustID" but this
>just gets the list of all customer IDs. (There is no need for an
>actual customer table).
>
>I could just grab all the records that fit the criteria of FieldX<>"Y"
>and pull unique CustIDs programatically, but I think it is really a
>job for SQLServer and not me. Thanks.
Hi dgk,
SELECT DISTINCT CustID
FROM Orders
WHERE FieldX <> 'Y'
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Raghav Mittal: "parameters in where clause"
- Previous message: Anthony Faull: "Re: what word will stop everything after it in a SQL script?"
- In reply to: dgk: "How to get distinct... under certain conditions"
- Next in thread: dgk: "Re: How to get distinct... under certain conditions"
- Reply: dgk: "Re: How to get distinct... under certain conditions"
- Messages sorted by: [ date ] [ thread ]