• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3088
  • Last Modified:

tricky PL/SQL question...

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
zollen
Asked:
zollen
  • 3
  • 2
1 Solution
 
jpkempCommented:
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
 
zollenAuthor Commented:

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


0
 
jpkempCommented:
SELECT MAX(KEY) FROM A WHERE KEY < :data;
0
 
zollenAuthor Commented:
Does MAX(...) also work with Date datatype??

0
 
jpkempCommented:
Yes
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now