All,
I have a table that holds a RuleId, Priority & Status. Status is a bit field.
[tab] -- If the priorities are the same for each RuleId then the RetStatus comparison should be an AND.
[tab] -- If the priorities are different the RetStats comparison should be an OR.
In the below table:
-- Rule 1 would eval to True (True or True)
-- Rule 2 would eval to False (False and True)
-- Rule 3 would eval to True (False or True)
Is there any way I can accomplish this logic in a query? I was thinking I could do something like:
Select RuleId, isTrue(RetStatus)
From tmpResults
Group By RuleId
I seem to have painted myself into a corner here. Anyone have any idea on how I could evaluate my bits by Group Id?
If you want to play with some test data:
* Sine scientia ars nihil est
* Respondeat superior
I have a table that holds a RuleId, Priority & Status. Status is a bit field.
[tab] -- If the priorities are the same for each RuleId then the RetStatus comparison should be an AND.
[tab] -- If the priorities are different the RetStats comparison should be an OR.
In the below table:
-- Rule 1 would eval to True (True or True)
-- Rule 2 would eval to False (False and True)
-- Rule 3 would eval to True (False or True)
Code:
RuleId Priority RetStatus
1 1 1
1 2 1
2 1 0
2 1 1
3 1 0
3 2 1
Is there any way I can accomplish this logic in a query? I was thinking I could do something like:
Select RuleId, isTrue(RetStatus)
From tmpResults
Group By RuleId
I seem to have painted myself into a corner here. Anyone have any idea on how I could evaluate my bits by Group Id?
If you want to play with some test data:
Code:
Create Table tmpResults (
RuleId smallInt
, Priority smallInt
, RetStatus bit
)
Insert Into tmpResults
Select 1, 1, 1
Insert Into tmpResults
Select 1, 2, 1
Insert Into tmpResults
Select 2, 1, 0
Insert Into tmpResults
Select 3, 1, 1
Insert Into tmpResults
Select 4, 1, 1
Insert Into tmpResults
Select 4, 1, 0
Insert Into tmpResults
Select 5, 1, 1
Insert Into tmpResults
Select 5, 2, 0
Insert Into tmpResults
Select 6, 1, 1
Insert Into tmpResults
Select 6, 1, 1
* Sine scientia ars nihil est
* Respondeat superior