tsql - vlookup style query in sql? -
i have simple vlookup query want write in sql cant seem apply of examples previous questions data.
i have 2 tables, totalstats has agentnumber column, , agentref lists every agentname against agentnumber.
i want simple query join 2 tables , create new column in totalstats shows agent name against each agentnumber.
i feel should simple i'm getting stuck! appreciate help, :)
select agentref.agentnumber ,totalstats.stat totalstats join agentref on totalstats.agentnumber=agentref.agentnumber
update:
assuming agentname in column "agentname"
select agentref.agentnumber ,agentref.agentname ,convert(varchar(255),agentref.agentnumber)+' '+agentref.agentname numbername ,totalstats.stat totalstats join agentref on totalstats.agentnumber=agentref.agentnumber
convert(varchar(255),agentref.agentnumber)+' '+agentref.agentname
puts number , name in same column blank inbetween
Comments
Post a Comment