我想编写以下查询:
SELECT ..., MIN(SomeBitField), ...
FROM ...
WHERE ...
GROUP BY ...
问题是,SQL Server不喜欢它,当我想计算位字段的最小值时,它返回错误Operand data type bit is invalid for min operator
。
我可以使用以下解决方法:
SELECT ..., CAST(MIN(CAST(SomeBitField AS INT)) AS BIT), ...
FROM ...
WHERE ...
GROUP BY ...
但是,还有更优雅的东西吗?(例如,可能有一个聚合函数,我不知道,该函数可以评估and
字段中位值的逻辑。)
Operand data type bit is invalid for min operator.