AdventureWorks Database: Evaluate whether the values in two columns are the same

SQL Query - AdventureWorks: Exercise-129 with Solution

129 From the following table write a query in SQL to evaluate whether the values in the MakeFlag and FinishedGoodsFlag columns are the same.

Sample table: production.Product

Click to view Full table

Sample Solution:

SELECT ProductID, MakeFlag, FinishedGoodsFlag, 
       WHEN MakeFlag = FinishedGoodsFlag THEN NULL  
       ELSE MakeFlag  
FROM Production.Product  
WHERE ProductID < 10;

Sample Output:

        1|false   |false            |        |
        2|false   |false            |        |
        3|true    |false            |true    |
        4|false   |false            |        |

SQL AdventureWorks Editor:

Practice Online

Contribute your code and comments through Disqus.

Previous: Change the display of product line categories with comment.
Next: Select data from first column that has a nonnull value.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

Convert Timestamp to date in MySQL Query:

DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'

Database: MySQL

Ref : https://bit.ly/3EJPnMQ