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 |
|
tejo_pan
Starting Member
10 Posts |
Posted - 2005-08-01 : 17:08:53
|
| Dears, how can I to take the first register (MIN(My_UI)) where My_UI as UniqueIdentifier?ex.:SELECT DISTINCT Column1, MIN(My_UI) FROM Table GROUP BY Column1But, if I set MIN, the SQL Server says "The minimum aggregate operationcannot take a uniqueidentifier data type as an argument."Thank you... |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-08-01 : 17:18:38
|
| you can only use comparison operators (=, <>, <, >, <=, >=) or check for NULL on uniqueidentifier columns.You cannot ORDER BY that column so TOP is out. It is really pretty limiting.Maybe a uniqueidentifier is not needed for your column, why are you using uniqueidentifier instead of a identity column?-ec |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-08-01 : 17:21:51
|
SELECT TOP 1 Column1, My_UI FROM Table GROUP BY Column1Or cast the uniqueidentifier to char(36), and do MIN on that.rockmoose |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2005-08-01 : 17:24:54
|
| You have a couple of work arounds...1) CAST the GUID to a string..2) Apply the CHECKSUM operator to it....DavidMA front-end is something that tries to violate a back-end. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-08-01 : 17:33:46
|
quote: Originally posted by rockmoose
SELECT TOP 1 Column1, My_UI FROM Table GROUP BY Column1Or cast the uniqueidentifier to char(36), and do MIN on that.rockmoose
the cast solution works. Good call.-ec |
 |
|
|
jeffreymfischer
Starting Member
10 Posts |
|
|
|
|
|
|
|