Solved

simple Oracle query question

Posted on 2007-12-04
6
1,105 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

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.

Join & Write a Comment

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

708 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

18 Experts available now in Live!

Get 1:1 Help Now