Solved

simple Oracle query question

Posted on 2007-12-04
6
1,106 Views
Last Modified: 2013-12-18
let say i have the foolowing table/data
OFFICER: Officer no
                 Officer name
      Officer address
         Officer Date-of-Birth
how do i show all the officers who are older than a given officer
0
Comment
Question by:aaxen
6 Comments
 
LVL 8

Expert Comment

by:YANN0S
ID: 20405402
SELECT <whatever you want to select>
WHERE yourtable
WHERE
SELECT <whatever you want to select from a>

  FROM yourtable a

 WHERE EXISTS (SELECT 1 FROM a.birthdate < b.birthdate

   AND <whatever criteria you use to identify the given officer >)

Open in new window

0
 
LVL 8

Expert Comment

by:YANN0S
ID: 20405420
Sorry, repost
SELECT <whatever you want to select from a>

  FROM yourtable a

 WHERE EXISTS (SELECT 1 

                 FROM  yourtable b 

                WHERE a.birthdate < b.birthdate

                  AND <whatever criteria you use to identify the given officer >)

 

Open in new window

0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20405430
I hope it should be like this.

declare @dob datetime
set @dob ='12/12/1960'
select * from OFFICER where  Officer Date-of-Birth
>=@age
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20405432
declare @dob datetime
set @dob ='12/12/1960'
select * from OFFICER where  Officer Date-of-Birth
<=@age
0
 
LVL 27

Accepted Solution

by:
sujith80 earned 500 total points
ID: 20408786
select * from Officer
where officer_date_of_birth < ( select officer_date_of_birth
                                from Officer
                                where officer_no = <your value> )
/
0
 

Author Comment

by:aaxen
ID: 20410237
hi yannos saw your code just one question, What does the " select 1 "means
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now