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 |
|
azamsharp
Posting Yak Master
201 Posts |
Posted - 2009-10-20 : 15:12:29
|
| Hi, I need to have a uniqueidentifier column in the select statement but I also have a groupby at the end. What can I do?Mohammad Azam www.azamsharp.net |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-20 : 15:15:51
|
| sorry your question is not clear. do you mean you need to group by uniqueidentifier column? |
 |
|
|
azamsharp
Posting Yak Master
201 Posts |
Posted - 2009-10-20 : 15:24:17
|
| Hi, I am selecting some records from the database table and one of the records in a uniqueidentifier. At the end of my query I am performing a group by. I cannot perform group by since one of the fields is uniqueidentifier. Also, I don't want that column/field to take part in the groupby. Mohammad Azam www.azamsharp.net |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-10-20 : 15:42:36
|
If you supply some sample data and expected output we can probably help you better. This link should help with that: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxBut, here is a guess:SELECT *FROM ( SELECT Col1, Col2, Col3, UniqueCol, ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3 ORDER BY UniqueCol) AS RowNum FROM MyTable ) AS TWHERE T.RowNum = 1 |
 |
|
|
|
|
|