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 |
|
Carat
Yak Posting Veteran
92 Posts |
Posted - 2009-02-06 : 05:51:47
|
| I have a query that has the following resultset:10254185 73175303 7323330610254185 73233306 7317530310285924 73035813 7328320710285924 73283207 7303581310293526 73037724 7310510310293526 73105103 7303772410301708 73313907 7334180610301708 73341806 7331390710301708 73341806 7331390010316355 73175303 73202803I only want the rows where the 2nd and 3rd column are different.As you can see in the first 8 rows, the 2nd and 3rd column are switched. I don't want these records in my result. Only the last 2 records are valid.How can I do this?Thanks. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-06 : 05:56:39
|
| can u post some data & ur query then it will better to understand |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-02-06 : 05:57:12
|
SELECT Col1, Col2, Col3FROM (SELECT Col1, CASE WHEN Col2 < Col3 THEN Col2 ELSE Col3 END AS Col2, CASE WHEN Col2 < Col3 THEN Col3 ELSE Col2 END AS Col3FROM Table1) AS fGROUP BY Col1, Col2, Col3HAVING COUNT(*) = 1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Carat
Yak Posting Veteran
92 Posts |
Posted - 2009-02-06 : 07:51:26
|
| It works great!Thanks Peso. |
 |
|
|
|
|
|