Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Query substr

Posted on 2008-06-26
3
Medium Priority
?
581 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
[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
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 1000 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 74

Expert Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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.  …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

721 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