Applying the MIN aggregate function to a BIT field

前端 未结 7 563
甜味超标
甜味超标 2020-12-05 01:36

I want to write the following query:

SELECT   ..., MIN(SomeBitField), ...
FROM     ...
WHERE    ...
GROUP BY ...

The problem is, SQL Ser

7条回答
  •  广开言路
    2020-12-05 02:05

    Try the following Note: Min represent And aggregate function , Max represent Or aggregate function

    SELECT   ..., MIN(case when SomeBitField=1 then 1 else 0 end), MIN(SomeBitField+0)...
    FROM     ...
    WHERE    ...
    GROUP BY ...
    

    same result

提交回复
热议问题