I have written the following query for group by
clause
我已经为group by子句编写了以下查询
SELECT OrderDetails.Quantity,
OrderDetails.options
FROM OrderDetails
Group by OrderDetails.Quantity,
OrderDetails.options
Order by OrderDetails.options DESC
OrderDetails.options
this column is of datatype nvarchar(255)
and quantity
is float
.
OrderDetails.options此列的数据类型为nvarchar(255),数量为float。
But I am getting error like this:
但我得到这样的错误:
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
除非使用IS NULL或LIKE运算符,否则无法比较或排序text,ntext和image数据类型。
I am new to SQL can any one please help me out
我是SQL新手,任何人都可以帮帮我
Thanks in advance!
提前致谢!
2 个解决方案
#1
1
Group by should have an aggregate operator so u might need to sum up the order quantity to get it done. Try this out :
Group by应该有一个聚合运算符,因此您可能需要总结订单数量才能完成它。试试这个:
SELECT sum(OrderDetails.Quantity),OrderDetails.options
FROM OrderDetails
Group by OrderDetails.options
Order by OrderDetails.options DESC
#2
4
Double check to make sure that the columns does not have the datatype TEXT or NText. If there is a column that has the datatype Text or NText then you can convert them to use NVARCHAR(MAX).
仔细检查以确保列没有数据类型TEXT或NText。如果存在具有数据类型Text或NText的列,则可以将它们转换为使用NVARCHAR(MAX)。
#1
1
Group by should have an aggregate operator so u might need to sum up the order quantity to get it done. Try this out :
Group by应该有一个聚合运算符,因此您可能需要总结订单数量才能完成它。试试这个:
SELECT sum(OrderDetails.Quantity),OrderDetails.options
FROM OrderDetails
Group by OrderDetails.options
Order by OrderDetails.options DESC
#2
4
Double check to make sure that the columns does not have the datatype TEXT or NText. If there is a column that has the datatype Text or NText then you can convert them to use NVARCHAR(MAX).
仔细检查以确保列没有数据类型TEXT或NText。如果存在具有数据类型Text或NText的列,则可以将它们转换为使用NVARCHAR(MAX)。