How to Solve this Sql Query

Posted by Jayakumars under Sql Server on 8/4/2015 | Points: 10 | Views : 1542 | Status : [Member] [MVP] | Replies : 2
Hi

Create Table Empinfos
(
EmpID int primary key identity(1,1),
DeptId int,
Empamount decimal(18,2),
EmpBonus decimal(18,2)
)



Create Table EmpPays
(
EmpID int
)

--Insert into Empinfos values(1,2000,3000)
--Insert into Empinfos values(2,4000,5000)
--Insert into Empinfos values(3,5000,6000)

--Insert into EmpPays values(1)
--Insert into EmpPays values(2)



Select * from Empinfos inner join EmpPays on Empinfos.EmpID=EmpPays.EmpID
--Empid deptid empamount empbonus empid
1 1 2000.00 3000.00 1
2 2 4000.00 5000.00 2

-- My need is how to check my select query empamount empbonus are equal or not
--for if equal means print 'yes' else ' no' how to solve this select query

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com



Responses

Posted by: Bandi on: 8/5/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Select * , CASE WHEN Empamount=Empbonus THEN 'Yes' ELSE 'No' END as flag 
from Empinfos inner join EmpPays on Empinfos.EmpID=EmpPays.EmpID


Is that you are looking for??

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandrikafk on: 8/5/2015 [Member] Starter | Points: 25

Up
0
Down
hi bandi
can you explain how its work..
thanks
sureshchandrika


Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response