Groups | Blog | Home
all groups > sql server programming > june 2004 >

sql server programming : How to get distinct... under certain conditions


Nigel Rivett
6/14/2004 4:59:01 PM
???

select distinct CustID
from Orders
where FieldX <> 'Y'


[quoted text, click to view]
oj
6/14/2004 11:02:14 PM
select custid
from tb
where x!=y
group by custid


[quoted text, click to view]

dgk
6/14/2004 11:46:42 PM
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
Hugo Kornelis
6/15/2004 9:28:42 AM
[quoted text, click to view]

Hi dgk,

SELECT DISTINCT CustID
FROM Orders
WHERE FieldX <> 'Y'


Best, Hugo
--

dgk
6/15/2004 2:24:34 PM
On Tue, 15 Jun 2004 09:28:42 +0200, Hugo Kornelis
[quoted text, click to view]

AddThis Social Bookmark Button