Solved

tricky PL/SQL question...

Posted on 2003-12-02
5
2,913 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

728 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