MAX运算符在位字段上的替代方法 [英] Alternative for MAX operator on bit fields

查看:174
本文介绍了MAX运算符在位字段上的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,该表的权限只有几位字段.我想对表中的行进行分组,并获得具有最高权限的结果. 因此,此表:

I have table with permissions that has few bit fields. I want to group rows in this table and get result with top permissions. So with this table:

UserId, Permisssion1,Permission2, Permisssion3 

以此行
13,1,0,0
13,0,1,0

With this to rows
13,1,0,0
13,0,1,0

我想得到:
13,1,1,0

I want to get:
13,1,1,0

问题是运算符MAX不适用于位字段.如何有效地做到这一点? (不使用CASE)

Problem is that operator MAX doesn't works on bit fields. How to do that in efficient way? (without using CASE)

推荐答案

简单到...

MAX(CAST(Permisssion1 AS tinyint))

您没有其他选择...

You don't have many other options...

这篇关于MAX运算符在位字段上的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆