Solved

simple Oracle query question

Posted on 2007-12-04
6
1,111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

627 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