declare @tab table ( id int, name varchar(100), salary int,doj date, Bonus varchar(10))
insert into @tab
SELECT 101, 'sr', 2000, '10/01/1996', NULL union all
SELECT 102, 'si', 4000, '12/12/2010', NULL union all
SELECT 103, 'sd', 5000, '11/06/1994', NULL union all
SELECT 104, 'sh', 6000, '09/02/1991' , NULL union all
SELECT 105, 'sa', 2000, '01/04/2015', NULL
/*
If an employee having more than 5 years experience then
that particular row should be highlighted and in bonus column
it should display "Yes".
*/
SELECT *, Case when DATEDIFF(YY, doj, GETDATE()) >5 then 'Yes' ELSE 'No' END as Bonus
FROM @tab
Here
@tab is table variable i used for the purpose of storing sample data...
You can replace
@tab with your actual table name
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Shreedar, if this helps please login to Mark As Answer. | Alert Moderator