Home » SQL & PL/SQL » SQL & PL/SQL » Display records not having particular code
Display records not having particular code [message #255877] Thu, 02 August 2007 04:31 Go to next message
kumarvk
Messages: 214
Registered: July 2004
Senior Member
Hi Experts,

I have a table with columns ID,TAG_NO,TAG_DATE,CODE. In this table the ID and CODE are unique.

for example
id tag_no tag_date code
1 ROO1 23-APR-07 T101
2 R001 23-APR-07 T102
3 R001 23-APR-07 T103
4 R001 23-APR-07 Z300
5 R002 23-APR-07 T101
6 R002 23-APR-07 T102
7 R003 23-APR-07 T101
8 R004 23-APR-07 T103
9 R004 23-APR-07 J101
10 R004 23-APR-07 J102
11 R005 23-APR-07 Z300

From this table I want to dislay only the tag_no don't have the code Z300.

I used the script like this

Select tag_no,tag_date from x where code != 'Z300' but it was displaying all the tag_no but I want my output like this be

TAG_NO
R001
R003
R004

Since R002 and R005 has used the code Z300. Can anyone help please?

Re: Display records not having particular code [message #255880 is a reply to message #255877] Thu, 02 August 2007 04:45 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
For instance,
select tag_no from mytable where tag_no not in (select tag_no from mytable where code='Z300')

Regards
Michel
Previous Topic: Grouping set of data
Next Topic: how to list all existing users of database
Goto Forum:
  


Current Time: Sat Dec 14 15:38:34 CST 2024