Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-01-19 : 08:10:53
|
| John writes "Hi, I have this tableTable Name:TestColumn name | datatype | size | value---------------------------Col1 varchar 10 BananaCol2 varchar 10 BananaCol3 varchar 10 AppleCol4 varchar 10 Appleand I want this resultBananaApplee.g. getting the non duplicate value from the column.I know there is a built in function that doing that using the Select statement? can you help please" |
|
|
RM
Yak Posting Veteran
65 Posts |
Posted - 2005-01-19 : 08:52:11
|
| What is the query that you are using ? From the example you've given, you will have to query the table like this ... Select Col1 From Test UNION Select Col2 From Test UNION Select Col3 From Test UNION Select Col4 From Test to get your desired outputand if you have this table structureTable Name:TestColumn name | datatype | size | value---------------------------Col1 varchar 10 BananaBananaAppleApplethen use SELECT DISTINCT col1 FROM Test |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-01-19 : 12:50:55
|
| [code]WHILE EXISTS( SELECT fruit FROM tab GROUP BY fruit HAVING COUNT(*) > 1 )BEGIN EAT fruit;ENDSELECT fruit FROM tab[/code]But if that gives you a stomachache, you can check out the distinct keyword.rockmoose |
 |
|
|
|
|
|