Solved

tricky PL/SQL question...

Posted on 2003-12-02
5
2,834 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

808 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