Solved

simple Oracle query question

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

Question has a verified solution.

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

Suggested Solutions

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

809 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