Solved

tricky PL/SQL question...

Posted on 2003-12-02
5
2,868 Views
Last Modified: 2012-05-04
TABLE  [A]
KEY
1      
3
7
10
15
25

I am trying to define a sql statement to perform the following function..

For example:
SQL(2) = 1
SQL(6) = 3
SQL(11) = 10
SQL(12) = 10
SQL(18) = 15
SQL(19) = 15
SQL(9) = 7
SQL (30) = 25
SQL(17) = 15
0
Comment
Question by:zollen
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:jpkemp
ID: 9864174
Please provide more information.

Are you asking for the code for a sql function called SQL that given the parameter values (e.g. 2,6,11,12,etc) returns the values you list (e.g. 1,3,10,10, etc)?

Are you asking how to create a PL/SQL table, and populate various rows in it according to the values in table "A"?
0
 

Author Comment

by:zollen
ID: 9864208

I just want a simple sql statement to locate the largest key that is smaller to my data.


0
 
LVL 5

Expert Comment

by:jpkemp
ID: 9864226
SELECT MAX(KEY) FROM A WHERE KEY < :data;
0
 

Author Comment

by:zollen
ID: 9864254
Does MAX(...) also work with Date datatype??

0
 
LVL 5

Accepted Solution

by:
jpkemp earned 50 total points
ID: 9864261
Yes
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

713 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