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 |
|
ceema
Yak Posting Veteran
80 Posts |
Posted - 2006-08-29 : 08:33:34
|
| Hello, I have a table Test with two columns a & b. In table I have values likeA B-----1 21 32 4I have to retrieve (any one of the distinct values of A and corresponding B value)a b-----1 22 4How it's possibleCeema |
|
|
Vivaldi
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-08-29 : 08:39:01
|
| well if thats the datawouldn't a simpleSELECT a,min(b) from abgroup by awork?________________________________________________"Wow, you have a master's degree in psychology? I will order a vodka martini, thanks" |
 |
|
|
ceema
Yak Posting Veteran
80 Posts |
Posted - 2006-08-29 : 08:44:04
|
| Hello, Data can be even character. So, minimum will not work.Ceema |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-29 : 08:47:13
|
can you post more sample data with the expected result ? KH |
 |
|
|
Vivaldi
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-08-29 : 08:47:47
|
I guess thats why they ask for the schema.an easy way is to add a sequential column to the tableand do a self join on the A column, where ab.key < ab2.keyquote: Originally posted by ceema Hello, Data can be even character. So, minimum will not work.Ceema
________________________________________________"Wow, you have a master's degree in psychology? I will order a vodka martini, thanks" |
 |
|
|
ceema
Yak Posting Veteran
80 Posts |
Posted - 2006-08-29 : 08:54:48
|
| Thank you Vivaldi, Thank you Vivaldi, it's working with min function as you told earlier, now I checked the same for character also.Thank you once gain and sorry for the wrong reply.Ceema |
 |
|
|
|
|
|
|
|