Solved

tricky PL/SQL question...

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

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
Comment Utility
SELECT MAX(KEY) FROM A WHERE KEY < :data;
0
 

Author Comment

by:zollen
Comment Utility
Does MAX(...) also work with Date datatype??

0
 
LVL 5

Accepted Solution

by:
jpkemp earned 50 total points
Comment Utility
Yes
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
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…
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now