Q:

Display record of 1 column comparing results of 2 column

I have provided with the table details and what is my expected output:

User (Id, PersonId, IsBlocked, BlockedReason)
Person (Id, FirstName, LastName)
Resume (Id, PersonId, IsActive)

Actual value would be  

IsBlocked (Yes - 1 or No - 0 )
IsActive (Yes - 1 or No - 0)

I need to know whether the user is Blocked, Active, Inactive. User can be in only 1 among all these 3 status.
For example, if user is blocked, he will not be active - So overall I need only 1 status. How can I write a SQL query for this case?

A:

In your case Person is the master table which contains all the people so you should left join the user and resume tables to that and use a case statement to get the status,
 SELECT P.ID,P.FirstName,p.LastName,case when T.IsBlocked=1 then 'Blocked'
               when R.IsActive =1 then 'Active'
               else  'Inactive' end as user_status
  FROM  Person P 
  LEFT JOIN User U on P.ID=U.PersonId
  LEFT JOIN Resume R on P.Id=R.PersonId

