I'm trying to do a request but I can't figure out how to do it.
Basically I have 1 table with 3 fields (field1,field2,field3).
Values in those 3 fields can be the same, but I want to select all of
these values only once (i.e distinct values)
Example
Field1 Field2 Field3
A A A
B E B
C F F
D G H
The select should return: A,B,C,D,E,F,G,H
I've tried with union and a select not in but I ended up with something
big and I got confused.
Can someone help ?
ThxSELECT col1
FROM YourTable
UNION
SELECT col2
FROM YourTable
UNION
SELECT col3
FROM YourTable
If that doesn't give the result you wanted then please post DDL and
sample data as described here:
http://www.aspfaq.com/etiquette.asp?id=5006
--
David Portas
SQL Server MVP
--|||Seems to work. Thanks !
Regarding the DDL, I've looked at it but I post my messages via the
google group thing and I'm not sure if I can upload attached stuff ?|||Glad it helped.
Put DDL and other scripts in the body of your message. Most people
can't or won't download attachments anyway.
--
David Portas
SQL Server MVP
--
No comments:
Post a Comment