troubleshooting Question

comparing two bit data type columns in SQL server 2008

Avatar of maqskywalker
maqskywalker asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
1 Comment1 Solution747 ViewsLast Modified:
Hi experts,

I have a table called MYTABLE with two bit data type columns I want to compare these two columns and depending on their value I want it to place the value in a 3rd column.

So here is my truth table, so the only time my third column should have the value of one is when COL1 and COL2 are both zero.


COL1      COL2     MyDesiredColumn
0              0                   1
0              1                   0
1               0                  0
1               1                  0
NULL        0                  0  
NULL       1                   0


Can anyone help me with this query?

So far I have this but I'm stuck on what I need to put on my third column to follow my truth table from above.

SELECT
        COL1
        , COL2
       ,
FROM MYTABLE

thanks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros