I wan to find the biggest age number [message #445544] |
Tue, 02 March 2010 07:24  |
rtumatt
Messages: 4 Registered: March 2010
|
Junior Member |
|
|
Hi i want a simple query to find out for example the highest age in the table. Sorry my terminology is not very good i am new to SQL and oracle. Thankyou and i appreciate any replies
|
|
|
|
|
|
|
Re: I wan to find the biggest age number [message #445561 is a reply to message #445544] |
Tue, 02 March 2010 08:20   |
rtumatt
Messages: 4 Registered: March 2010
|
Junior Member |
|
|
Table:
create table o_employees (
eno number(4) not null primary key,
person person_type,
hdate date
);
Person type:
create type person_type as object (
name varchar2(30),
address address_type,
phones phones_varray_type);
Example insert:
insert into o_employees values(1000,person_type('Jones', address_type('123 Main St','Wichita','KS',67226),
phones_varray_type('316-555-1212',null,null)),
'12-DEC-95');
hope this helps.
I am getting this error:
SQL> select sysdate-<hdate>
2 from o_employees;
select sysdate-<hdate>
*
ERROR at line 1:
ORA-00936: missing expression
Thankyou again for the replies i really do appreciate this.
|
|
|
Re: I wan to find the biggest age number [message #445563 is a reply to message #445544] |
Tue, 02 March 2010 08:27   |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The <> are just there to highlight the fact that you need to replace that part of the example with the correct column(s).
Column names in sql queries are never actually wrapped in <>
so:
select sysdate- hdate
from o_employees;
|
|
|
|
|
Re: I wan to find the biggest age number [message #445634 is a reply to message #445568] |
Wed, 03 March 2010 01:22  |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
rtumatt wrote on Tue, 02 March 2010 15:37The answer to my question is something like:
select max(hdate) from o_employees;
Actually, if you want the person that's been working there for the longest period, you want to use min, not max.
|
|
|