Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Boolean Help

Status
Not open for further replies.

boflexson

Programmer
Oct 16, 2001
74
0
0
US
Ok, this is tricky:

Given the following example table:
Id, SeqNum, BoolType, BoolValue
1, 1, 1, 1
1, 2, 1, 0
2, 1, 1, 1
2, 2, 1, 1
3, 1, 1, 1
3, 2, 0, 0

Id seperaties the entries,
BoolType 1 = And, 2 = Or
BoolValue 0 = False, 1 = True

So For Id 1, we need to determine if it is true
In english: If Seq 1 AND Seq2 Then
ID2: If Seq 1 AND Seq2 Then
ID3: If Seq 1 OR Seq2 Then

I could call a procedure for each Id or (if possible) make 1 call for the whole thing.

Of course I can do cursors, but let's find a way to do it with out any.

Limitations: The seqnum can go as high as 3

Any ideas, I'll post my progress as I go as well.
-Bo


-Adam T. Courtney
 
Here is the sql script to generate a test table (TestBool) to help with the work:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TestBool]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TestBool]
GO

CREATE TABLE [dbo].[TestBool] (
[Id] [int] NOT NULL ,
[SeqNum] [int] NOT NULL ,
[BoolType] [int] NOT NULL ,
[BoolValue] [bit] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TestBool] ADD
CONSTRAINT [PK_TestBool] PRIMARY KEY CLUSTERED
(
[Id],
[SeqNum]
) ON [PRIMARY]
GO


-Adam T. Courtney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top