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 |
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2009-07-29 : 07:01:06
|
| Morning,I have been asked to write a query that am not sure how to do.I have three colunms sName,iCode,sDom in a table. Example of the data is below.Modern Times Group AB Cl A,56853,SEModern Times Group AB Cl B,56853,SEModern Times Group MTG AB,164025,SEModern Water,157097,GBModernform Group PCL,38159,THModernform Group PCL Fgn,38159,THModernform Group PCL NVDR,38159,THNow i want to return the icode with a distinct value, but also return any one of the sName values. I don't mind which one is return for each icode.any help would be great |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-29 : 07:03:47
|
[code]select icode, min(sName)from yourtablegroup by icode[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2009-07-29 : 07:10:41
|
Cheers, you're a star.I didn't realise it was that easy to do.quote: Originally posted by khtan
select icode, min(sName)from yourtablegroup by icode KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
|
|
|
|
|