Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi all,

id name status
1 harry 5
1 harry 10
1 harry 15
2 barry 5
2 barry 10
3 ben 5
3 ben 10
3 ben 15
4 ian 5
4 ian 10
5 jolly 5
5 jolly 10



Output

I need the employee whose status doesn't have 15

barry
ian
jolly


Thanks
Posted

SQL
Select id,name,status from Employee where Status!=15


It is a very basic query of SQL. You must know these. Please learn it yourself.

Best of Luck!
 
Share this answer
 
first learn the basic query from www.w3schools.com website.this is good website for beginner

Select id,name,status from Employee where Status!=15
 
Share this answer
 
Comments
3796068 31-Jan-12 23:31pm    
Dear sir,Your query is not working.Its showing all names but i only need barry
ian
jolly

Thanks
Hi,

this will help


Declare @Employee table
(
  id int,
  name varchar(50),
  status1 int
)

Insert Into @Employee 
values 
(1, 'anvas',10),
(2, 'anvas',5),
(3, 'Deepthi',15),
(4, 'Sudeep',15)

Select distinct(name) id,status1 from @Employee where Status1!=15
 
Share this answer
 
Here it is :
SQL
SELECT  distinct name
  FROM TableName e
  where not exists(select id from TableName where status = 15 and name = e.name)


Change TableName to your table name !

Hope it helps
 
Share this answer
 
Comments
3796068 1-Feb-12 11:09am    
Thanks brother(Amir) for the help.
Amir Mahfoozi 2-Feb-12 3:30am    
You're welcome brother :)

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