Click here to Skip to main content
14,329,949 members
Rate this:
Please Sign up or sign in to 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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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!
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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
   
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
Rate this:
Please Sign up or sign in to vote.

Solution 3

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
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

Here it is :
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
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100