Solved

Query substr

Posted on 2008-06-26
3
570 Views
Last Modified: 2013-12-07
Can someone explain what this line below is accomplishing. I am fairly new to PLSQL.  

substr(max((lpad(percent,10,'0') | | line_num)),11,6)
0
Comment
Question by:Medicine1
  • 2
3 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 21876184
assuming percent and line_num are columns in a table it's something like this.

given a percent like 17, pad it with zeroes out to 10 characters.

0000000017
then append the line_num column to it.  so if Line_num is 8 then you'll get a string

00000000178

do that for every column and find the maximum value of all of them.
so

000001689156 will be greate than 00000000178


then with that maxium value (in this case 000001689156)  start with the 11th charcter and read
forward 6 characters (or until you run out of characters) and return that.

so...  given 000001689156
that would return "6"

if you had 0000123456987654321  you would get 987654





0
 

Author Comment

by:Medicine1
ID: 21876379
Is the | | (bars) combining the numbers?
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 21876915
yes, that's the string concatenation symbol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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 recover a database from a user managed backup

920 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

15 Experts available now in Live!

Get 1:1 Help Now