dbTalk Databases Forums  

Return keyword from max value held in multiple columns

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Return keyword from max value held in multiple columns in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tim Frawley
 
Posts: n/a

Default Return keyword from max value held in multiple columns - 12-20-2004 , 02:23 PM






I am attempting to return a keyword of 'Novice', 'Journey' or 'Expert'
based on dates held in three columns and the userid.

The date references the day when that user achieved that level of
competence. A sample of the data would be like:

create table t_ (userid char(3),
novice date,
journey date,expert date)

insert into t_ values ('ABC',
to_date('10/15/2003','dd-mon-yyyy'),
to_date('12/15/2003','dd-mon-yyyy'),
to_date('1/15/2004','dd-mon-yyyy'))

insert into t_ values ('DEF',
to_date('1/15/2004','dd-mon-yyyy'),
null,
to_date('12/15/2003','dd-mon-yyyy'))

insert into t_ values ('XYZ',
to_date('10/15/2003','dd-mon-yyyy'),
to_date('12/15/2003','dd-mon-yyyy'),
null)

My other issues are that the dates may not be Novice least to Expert
max (just in case entry is fouled up) and the issue of nulls.
Can anyone help me?


Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Return keyword from max value held in multiple columns - 12-20-2004 , 06:13 PM






Tim Frawley wrote:
Quote:
I am attempting to return a keyword of 'Novice', 'Journey' or 'Expert'
based on dates held in three columns and the userid.

The date references the day when that user achieved that level of
competence. A sample of the data would be like:

create table t_ (userid char(3),
novice date,
journey date,expert date)

insert into t_ values ('ABC',
to_date('10/15/2003','dd-mon-yyyy'),
to_date('12/15/2003','dd-mon-yyyy'),
to_date('1/15/2004','dd-mon-yyyy'))

insert into t_ values ('DEF',
to_date('1/15/2004','dd-mon-yyyy'),
null,
to_date('12/15/2003','dd-mon-yyyy'))

insert into t_ values ('XYZ',
to_date('10/15/2003','dd-mon-yyyy'),
to_date('12/15/2003','dd-mon-yyyy'),
null)

My other issues are that the dates may not be Novice least to Expert
max (just in case entry is fouled up) and the issue of nulls.
Can anyone help me?
Probably not based on whagt you posted. For one thing your table t_,
where did the name come from?, isn't relational. What school is
giving this out as homework?

--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


Reply With Quote
  #3  
Old   
Mark D Powell
 
Posts: n/a

Default Re: Return keyword from max value held in multiple columns - 12-20-2004 , 07:02 PM



Tim, Look up the CASE statement in the SQL manual or your book. If you
are using an old version of Oracle and the case statement is not
available look up the decode function.

HTH -- Mark D Powell --


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.