Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the table named Transfers has a column TraType when the value of TraType=1 then it is internal Transfer and if TraType=2 then iT is External Transfer. I have to show the Internal Transfer text in select statement or External Transfer text in the select statement based on TraType. The query is as below.
Thanks in advance.

SQL
select TraAsset,TraType,TraDate,TraFrom TraToTranCompanyID
from Transfers
where TraApprvBy is not null and TraApprvDate is not null and TranStatus='Approved'
Posted
Updated 14-Dec-14 0:27am
v2
Comments
OriginalGriff 14-Dec-14 6:13am    
And?
What does it do that you didn't expect, or not do that you did?
What help do you need?
Sumon562 14-Dec-14 6:22am    
I have to show One field in select statement that is Internal Transfer or external Transfer depend on TraType.

1 solution

Try this:
SQL
DECLARE @tmp TABLE(TraType INT, TraName VARCHAR(50))

INSERT INTO @tmp (TraType, TraName)
VALUES(1, 'Internal transfer'), (2, 'External transfer')

SELECT t1.TraAsset, t1.TraType, t2.TraName, t1.TraDate, t1.TraFrom, t1.TraToTranCompanyID
FROM Transfers AS t1 INNER JOIN @tmp AS t2 ON t1.TraType = t2.TraType
WHERE t1.TraApprvBy is not null and t1.TraApprvDate is not null and t1.TranStatus='Approved'
 
Share this answer
 
Comments
Sumon562 14-Dec-14 6:33am    
Thanks a lot Mr. Maciej Los
Maciej Los 14-Dec-14 7:51am    
You're very welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900