SQL JOIN and CASE -


i hope can me simple query i've been working on few days. new sql , have read answers similar questions, did not find looking for.

my goal query information 2 different tables, , display in readable manner. successful in creating following query, displays of information need:

select     pa.entityname,     pa.entitytype,     po.name,     po.feature policyassociations pa join policies po on po.id = pa.policyid     pa.entitytype='1'     or     pa.entitytype='2' group po.name, pa.entityname 

now need change output of entitytype column (displayed 'object type') numerical values text, e.g. display word 'computer' instead of '1' , 'user' instead of '2'.

the following query works independently, have failed incorporate these strings main join query in many variations:

select entitytype, case   when entitytype = '1' 'computer'   when entitytype = '2' 'user' end policyassociations 

do mean this? seems basic of solution.

select     pa.entityname,     case when entitytype = '1' 'computer'         when entitytype = '2' 'user'end entitytypestr,     pa.entitytype,     po.name,     po.feature policyassociations pa join policies po on po.id = pa.policyid     pa.entitytype='1'     or     pa.entitytype='2' 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -