Ryan Gadsdon
Ryan Gadsdon

Reputation: 2378

"Operand data type text is invalid for min operator" SQL Server

I am getting this error "Operand data type text is invalid for min operator" when trying to run this code

Select
UserID,
min(Description)
FROM Table1
GROUP BY UserID

I have tried

select min(cast(AttributeValue as varchar(max)))

But i couldnt get it working.

Is there any way around this? Thanks

Upvotes: 1

Views: 3568

Answers (2)

Anagha
Anagha

Reputation: 918

Try This:

Select UserID,min(CAST(Description AS VARCHAR(50)))
FROM Table1
GROUP BY UserID

Upvotes: 2

Vikram Jain
Vikram Jain

Reputation: 5588

"Min" function not worked with "group by". So, please try with:

Select UserID   
FROM Table1
GROUP BY UserID

Upvotes: 0

Related Questions