Re: How to get distinct... under certain conditions

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 06/15/04


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)