Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1118
  • Last Modified:

simple Oracle query question

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
aaxen
Asked:
aaxen
1 Solution
 
YANN0SCommented:
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
 
YANN0SCommented:
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
 
Shanmuga SundaramDirector of Software EngineeringCommented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Shanmuga SundaramDirector of Software EngineeringCommented:
declare @dob datetime
set @dob ='12/12/1960'
select * from OFFICER where  Officer Date-of-Birth
<=@age
0
 
SujithData ArchitectCommented:
select * from Officer
where officer_date_of_birth < ( select officer_date_of_birth
                                from Officer
                                where officer_no = <your value> )
/
0
 
aaxenAuthor Commented:
hi yannos saw your code just one question, What does the " select 1 "means
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now