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 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-10-12 : 09:56:54
|
| Something simple here, just not finding the right way.I have the following: SELECT DISTINCT fld1, fld2 FROM tbl1Ok, this will bring back duplicates of fld1 because fld2 is different for the row.What I need is no duplicates of fld1 but also bring back fld2 of that row.Thanks,Zath |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-12 : 10:15:43
|
| Need some sample data, and expected results, to better understand the question pleaseOtherwise we're just guessing!Kristen |
 |
|
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-10-12 : 10:18:48
|
| Sorry, as the sql is above it will return:fld1 fld2x 2x 3y 5z 0What it needs to return is:fld1 fld2x 2y 5z 0 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-12 : 10:20:36
|
| Isnt it as simple as this?select fld1,min(fld2) as fld2 from tablegroup by fld1MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-12 : 10:22:31
|
| Why x 2rather thanx 3??Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-12 : 10:27:42
|
quote: Originally posted by Kristen Why x 2rather thanx 3??Kristen
Min, Max or any MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-12 : 10:32:14
|
Or, I expect, "First one in the database" ... |
 |
|
|
|
|
|