Alternative for MAX operator on bit fields

…衆ロ難τιáo~ 提交于 2019-12-21 06:57:31

问题


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 

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

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

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


回答1:


As simple as...

MAX(CAST(Permisssion1 AS tinyint))

You don't have many other options...



来源:https://stackoverflow.com/questions/9077263/alternative-for-max-operator-on-bit-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!