Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

tricky PL/SQL question...

Posted on 2003-12-02
5
Medium Priority
?
3,027 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 200 total points
ID: 9864261
Yes
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

604 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