It's not a secret anymore!*
The moose likes JDBC and the fly likes SqlHelp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SqlHelp" Watch "SqlHelp" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Dno Status
10 null
10 aa
20 null
20 bb
20 cc
30 null

Display REcord that has a null status but has only one record.

output 30 null
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30130

You need to use a subquery. It is something like this:

select * from table t1
where t1.status is null and 1 =
(select count(*) from table t2 where t1.dno = t2.dno)
[ October 22, 2004: Message edited by: Jeanne Boyarsky ]

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
jQuery in Action, 2nd edition
subject: SqlHelp
Similar Threads
how to get the oldest timestamp record in an array list
IllegalArgumentException when using clj-record's create function
another array problem
Clarifications on session attribute
what is the meaning of socket write error