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-04 : 08:41:58
|
| Bong writes "Hi there! I posted this inquiry before and haven't received any reply yet. I have a table with 2 fields on it:Field1 Field2 1 2 2 1 3 4 4 3 5 6I want to run a query that outputs to a cursor with the ff. results: Field1 Field2 1 2 3 4 5 6I consider recs#2,4 duplicates of recs#1,3. There shouldbe no more than one occurence of a value in any field.Need any ideas on how this could be done using SQL code." |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-01-04 : 09:06:52
|
| something like this:select m1, m2 from tUNIONselect m2, m1 from t |
 |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2005-01-04 : 10:33:06
|
| Hope this works,Declare @tbl table (i int, j int)insert into @tblselect 1 a, 2 b union allselect 2 ,1 union allselect 3, 4 union allselect 4, 3 union allselect 5, 6 SELECT distinct case when j < i then j else i end, case when i > j then i else j endfrom @tbl aEnjoy working |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-01-06 : 07:31:16
|
Try thisSelect distinct Field1, Field2 from Table where Field1 <=Field2 Madhivanan |
 |
|
|
|
|
|