Finding the minimum value across multiple rows (not in a single column)
Hello,
I am running some ad-hoc SQL to test a website implementation of a spec. The ad-hoc sql gives me a set of date values for a specific widget (called a Task). I need to find the Minimum of either (Task.EndDate + 1 year) or the MAX date from the list
of other dates. I can easily get all of these dates, and compare them visually, but I'm not sure how to make SQL give me just the single value that I want. In the image below, you can see the results. The blue cell is the value I should get if I were to retrieve
a single value.
select
[EndDate+12Mo] = DATEADD(year,1,t.EndDate)
, [TaskEdit] = t.EditTS
, [ResearchEdit] = (select x.editts from Research x where t.researchid = x.researchid)
, [DeliverableEdit] = (select max(x.EditTS) from Deliverable x where t.taskid = x.taskid)
, [RTPEdit] = (select max(x.EditTS) from ResTaskParticipant x where (t.taskid = x.taskid and t.researchid = x.researchid) or (t.researchid = x.researchid and x.TaskID is null) )
, [RelatedTaskEdit] = (select max(x.EditTS) from Task_Related x where t.taskid = x.Task1ID or t.TaskID = x.Task2ID)
, [CrosscutEdit] = (select max(x.EditTS) from Task_Crosscut x where t.taskid = x.taskid)
, [TaskFundingEdit]= (select max(x.EditTS) from TaskFunding x where t.taskID = x.taskID)
, [ContractFundingEdit]= (select max(x.EditTS) from TaskFunding x inner join ContractFunding y on x.ContractFundingID = y.ContractFundingID where t.taskID = x.taskID)
from task t
where
t.tasknumber =
'2123.001'
Thanks!
Jennifer
Sounds like this to me
select CASE WHEN [EndDate+12Mo] < MAX(dt) THEN [EndDate+12Mo] ELSE MAX(dt) END AS YourDateValue
from
SELECT [EndDate+12Mo],dt
from
select
[EndDate+12Mo] = DATEADD(year,1,t.EndDate)
, [TaskEdit] = t.EditTS
, [ResearchEdit] = (select x.editts from Research x where t.researchid = x.researchid)
, [DeliverableEdit] = (select max(x.EditTS) from Deliverable x where t.taskid = x.taskid)
, [RTPEdit] = (select max(x.EditTS) from ResTaskParticipant x where (t.taskid = x.taskid and t.researchid = x.researchid) or (t.researchid = x.researchid and x.TaskID is null) )
, [RelatedTaskEdit] = (select max(x.EditTS) from Task_Related x where t.taskid = x.Task1ID or t.TaskID = x.Task2ID)
, [CrosscutEdit] = (select max(x.EditTS) from Task_Crosscut x where t.taskid = x.taskid)
, [TaskFundingEdit]= (select max(x.EditTS) from TaskFunding x where t.taskID = x.taskID)
, [ContractFundingEdit]= (select max(x.EditTS) from TaskFunding x inner JOINContractFunding y on x.ContractFundingID = y.ContractFundingID where t.taskID = x.taskID)
from task t
where
t.tasknumber =
'2123.001'
)t1
UNPIVOT(dt FOR cat IN ([TaskEdit]
, [ResearchEdit]
, [DeliverableEdit]
, [RTPEdit]
, [RelatedTaskEdit]
, [CrosscutEdit]
, [TaskFundingEdit]
, [ContractFundingEdit]))u
)r
GROUP BY [EndDate+12Mo]
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Concatenate a column value across multiple rows - PDW
We are using PDW based on SQL2014. We require an efficient logic on how to concatenate a column value across multiple rows. We have the following table
T1
(CompanyID, StateCD)
Having following rows:
1 NY
1 NJ
1 CT
2 MA
2 NJ
2 VA
3 FL
3 CA
We need a code snippet which will return following result set:
1
CT,NJ,NY
2
MA,NJ,VA
3
CA,FL
We have tried built-in function STUFF with FOR XML PATH clause and it is not supported in PDW. So, we need a fast alternative.Hi Try this:
SELECT * INTO #ABC
FROM
SELECT 1 AS ID,'NY' AS NAME
UNION
SELECT 1 AS ID,'NJ' AS NAME
UNION
SELECT 1 AS ID,'CT' AS NAME
UNION
SELECT 2 AS ID,'MA' AS NAME
UNION
SELECT 2 AS ID,'NJ' AS NAME
UNION
SELECT 2 AS ID,'VA' AS NAME
UNION
SELECT 3 AS ID,'FL' AS NAME
UNION
SELECT 3 AS ID,'CA' AS NAME
)A
CREATE TABLE ##CDB (ID INT, NAME NVARCHAR(800))
DECLARE @TMP VARCHAR(MAX),
@V_MIN INT,
@V_MAX INT,
@V_COUNT INT
SELECT @V_MIN=MIN(ID),@V_MAX=MAX(ID) FROM #ABC
SET @V_COUNT=@V_MIN
WHILE @V_COUNT<=@V_MAX
BEGIN
SET @TMP = '' SELECT @TMP = @TMP + CONVERT(VARCHAR,NAME) + ', ' FROM #ABC
WHERE ID=@V_COUNT
INSERT INTO ##CDB (ID, NAME) SELECT @V_COUNT AS ID ,CAST(SUBSTRING(@TMP, 0, LEN(@TMP)) AS VARCHAR(8000)) AS NAME
SET @V_COUNT=@V_COUNT+1
END
SELECT * FROM ##CDB
OR
SELECT * INTO #ABC
FROM
SELECT 1 AS ID,'NY' AS NAME
UNION
SELECT 1 AS ID,'NJ' AS NAME
UNION
SELECT 1 AS ID,'CT' AS NAME
UNION
SELECT 2 AS ID,'MA' AS NAME
UNION
SELECT 2 AS ID,'NJ' AS NAME
UNION
SELECT 2 AS ID,'VA' AS NAME
UNION
SELECT 3 AS ID,'FL' AS NAME
UNION
SELECT 3 AS ID,'CA' AS NAME
UNION
SELECT 5 AS ID,'LG' AS NAME
UNION
SELECT 5 AS ID,'AP' AS NAME
)A
CREATE TABLE ##CDB (ID INT, NAME NVARCHAR(800))
DECLARE @TMP VARCHAR(MAX),
@V_MIN INT,
@V_MAX INT,
@V_COUNT INT
SELECT @V_MIN=MIN(ID),@V_MAX=MAX(ID) FROM #ABC
SET @V_COUNT=@V_MIN
WHILE @V_COUNT<=@V_MAX
BEGIN
SET @TMP = '' SELECT @TMP = @TMP + CONVERT(VARCHAR,NAME) + ', ' FROM #ABC
WHERE ID=@V_COUNT
SELECT @V_COUNT AS ID ,CAST(SUBSTRING(@TMP, 0, LEN(@TMP)) AS VARCHAR(8000)) AS NAME INTO #TEMP
INSERT INTO ##CDB (ID, NAME) SELECT ID, NAME FROM #TEMP WHERE NAME<>''
DROP TABLE #TEMP
SET @V_COUNT=@V_COUNT+1
END
SELECT * FROM ##CDB
Thanks Shiven:) If Answer is Helpful, Please Vote -
How to find the Minimum value of a Measure across a Custom Dimension
I am having Trouble figuring the best approach for the given below scenario.
I have a measure called Inventory which is basically by Product by Part by Geography across a Time period.
Part dimension is 3 levels Deep.
Part
--Configuration_NAME
- Part_ID
the Requirement is to Pick the the Minimum Inventory Values of a product across the Configuration_Name and Store this information in another measure called Inventory_Min.
here is how the data mock up looks like
config1 - product1- Inventory - 100 (Period1)
config2- product1-Inventory-200 (Period1)
config3-Product1-inventory-400 (Period1)
now the output expected is
Config1-Product1-Inventory_MIN - 100(Period1) since for this product across 3 configs, 100 is the minimum inventory.
I am trying to use @RANGE,@MINS but i am not sure how to tell essbase to go down the Part Dimensions, level 1 members and not across the Period.
any help or points will be appreciated.
Thanks,
SriramHello,
what about @MINSRANGE ?
http://docs.oracle.com/cd/E17236_01/epm.1112/esb_tech_ref/minsrange.html
Inventory_MIN = @MINSRANGE(SKIPBOTH, "Inventory" , @LIST("config1","config2","config3"))
should give the result,
if you FIX @RELATIVE("Part",-1) to grab level 1 members.
and you can extend expression something like
Inventory_MIN = @MINSRANGE(SKIPBOTH, Inventory , @CHILDREN(@CURRMBR("Part")))
Hope it helps,
Ahmet -
Get the minimum value from a cursor
Hi,
i have a cursor that returns the following two columns in a stored procedure. now i want to find the minimum value of SORT NUMBER column .
Can anybody give me an idea.....
create or replace procedure get_min
as
cursor c1 is
select group_number
, sort_number
from group_table
v_min number;
begin
for c1_rec in c1
select min(c1_rec.sort_number) into v_min ;
end;
GRP_NUMBER SORT NUMBER
1001 9978
1002 9979
1003 9946 thanks in advance.OPTION1
I'm guessing your stored procedure loops through the cursor (goes record by record and does something), correct? If it loops through all records, then
1. first define variable which will hold minimum value e.g.
my_min_value number := 0;
2. then add this inside the loop (as you loop through all records, my_min_value will get assign the lowest value)
my_min_value := LEAST(my_min_value, c1_rec.sort_number);
when the cursor is done looping through all records, you get your minimum value
small note: make sure c1_rec.sort_number is not null or you know how null works with least function
OPTION2
if you don't loop through all records (maybe have a condition and stop looping), then you can always change the SQL and add the minimum value to the SQL, there are multiple ways to do this, this is one of them - I hope there is no typo - it's 8pm :-)
select group_number
, sort_number,
min(sort_number) OVER ( )
from group_table
OPTION3
get rid of cursor, there are probably 5000 better choices :-) -
Finding the minimum with a for statement
Ok so Ive got this program and I need to find the minimum value from the 10 values that are entered by a user, my problem is I cant figure out to initialize the variable minNum, Im not sure how to do it with a for loop, if I set it to zero, then zero will always be the minimum, so Im not sure how to make it so it takes the first value as the minimum then compares each value entered after that to see if the value is smaller, and I have to use a for loop for this problem, my professor specified which loop to use, so heres the code:
import java.util.Scanner;
public class Exercise52Chapt6
public static void main(String[] args)
Scanner scan = new Scanner(System.in);
int minNum; // stores the minimum of 10 numbers
int number; // stores the current input
for ( int i = 1; i <= 10; i++ )
System.out.print( "Enter an integer > " );
number = scan.nextInt( );
if(number < minNum)
minNum = number;
// process results by printing the minimum
System.out.println( "The minimum is: " + minNum );
}import java.util.Scanner;
public class Test
public static void main(String[] args)
Scanner scan = new Scanner(System.in);
int minNum=0; // stores the minimum of 10 numbers
int number; // stores the current input
for ( int i = 1; i <= 10; i++ )
System.out.print( "Enter an integer > " );
number = scan.nextInt( );
if(i==1){
minNum = number;
continue;
if(number < minNum)
minNum = number;
// process results by printing the minimum
System.out.println( "The minimum is: " + minNum );
} -
How do I find the closest value to a constant in an array
I have an array of floating numbers and I want to find a value in that array that is closest to a floating constant. For example if I have the array 5.9, 2.8, 3.7, 5.8, 6.9, and if I have the constant 5.4, how would I find the closest value to 5.4 in the array, which in this case would be 5.8. The only approach I can think of is to subtract each value in the array from 5.8 and find the minimum value of an array which would be created from the differences. Is there a better approach?
Thank you.Just be sure to take the absolute value of the difference and your proposed method is fine.
-
Finding minimum value in each row using dynamic query
need to find the minimum and maximum value from each row using dynamic query
[from curr] will be given as input
TukyDECLARE @t TABLE(a INT,b INT,c INT);
INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
SELECT *
, ( SELECT MAX(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MaxVal
, ( SELECT MIN(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MinVal
FROM @t;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to find a data with the minimum value I get without using sub query
Currently, I manage to get a record by using subquery to find the minimum number, eg:
SELECT TAccTrn.ASysCde
FROM TAccTrn
WHERE TAccTrn.AAccTrnNum=(SELECT Min(TAccTrn.AAccTrnNum)
FROM TAccTrn, TDbtSchCltDtl
WHERE TDbtSchCltDtl.ASrcRefId=TAccTrn.ASrcRefId
AND TDbtSchCltDtl.ASrcRefSubId=TAccTrn.ASrcRefSubId
AND TDbtSchCltDtl.ASrcRefSeq=TAccTrn.ASrcRefSeq)
Is there any more idea without using the subquery?Hi ,
What about using an in-line view and the row_number () analytic function...????
Here is an example....
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 18/12/1980 800,00 20
7499 ALLEN SALESMAN 7698 20/02/1981 1600,00 300,00 30
7521 WARD SALESMAN 7698 22/02/1981 1250,00 500,00 30
7566 JONES MANAGER 7839 02/04/1981 2975,00 20
7654 MARTIN SALESMAN 7698 28/09/1981 1250,00 1400,00 30
7698 BLAKE MANAGER 7839 01/05/1981 2850,00 30
7782 CLARK MANAGER 7839 09/06/1981 2450,00 10
7788 SCOTT ANALYST 7566 18/04/1987 3000,00 20
7839 KING PRESIDENT 17/11/1981 5000,00 10
7844 TURNER SALESMAN 7698 08/09/1981 1500,00 0,00 30
7876 ADAMS CLERK 7788 21/05/1987 1100,00 20
7900 JAMES CLERK 7698 03/12/1981 950,00 30
7902 FORD ANALYST 7566 03/12/1981 3000,00 20
7934 MILLER CLERK 7782 23/01/1982 1300,00 10
14 rows selectedUsing a solution like the one you don't want ...(a subquery) i would write....
SQL> select ename from emp
2 where hiredate=(select min(hiredate) from emp)
3 /
ENAME
SMITHWhereas , using an in-line view....
SQL> select ename from
2 (
3 select ename,row_number() over(order by hiredate asc) row_num from emp
4 )
5 where row_num=1
6 /
ENAME
SMITHIs it acceptable...????
Regards,
Simon -
How to find the RGB Values of a Color for Hyperion
When customizing your Hyperion forms, we come across situations where we need the exact RGB value of a given color. This article explains a simple technique to find the RGB values using MS Paint and the Calculator applications that come as standard applications with your operating system.
Here are the steps to find the exact RGB value of a given color.
1) View your Hyperion form using IE, scroll down until you see the color you want to find the RGB value and press the "Print Screen" button (in your keyboard).
2) Open MS Paint and click Edit -> Paste or simply Ctrl+V. What you saw in the browser will be copied as a new untitled image.
3) Select the Color Picker tool and click on an area that has the color you want to match.
4) Now go to Edit Colors... option and click on the "Define Custom Colors >>" button. The color you picked will be selected on this palette. At the bottom right hand corner you will see the Red, Green and Blue values you need. Note down the R,G,B values (given in decimal).
5) Now we need to find out the hexa-decimal values that correspond to those decimal values. This is where we use the simple Calculator. Open the Calculator application from Program -> Accessories. Switch to the scientific mode by clicking View ->Scientific.
6) By default it will be in the decimal number mode. Enter the R value (238 in this example) and click on the Hex radio button. The corresponding hexa-decimal value (EE in this case) will be shown in the dial.
The selected color in this case has the same value for R, G and B. (In fact, all shades of gray has the same values for R, G and B.) Therefore, the RGB value of the background color that we need is #eeeeee. Repeat step 6 to find out the hex value for the Green and Blue elements, if they are different.
Tip:
If you find it difficult to pick a color, zoom the image by pressing Ctrl+PageDown or using View -> Zoom -> Custom... option.These tips are to find the RGB color of HFM default row where row is text and text lines in data columns are also visible to business users as Yellow as an input cell. By applying the same RGB color you can apply the same color to your data cells or rows. This post shows how to identify color from any web view-able object.
Regards,
Manaf -
How do you find the average value of all the data between two points on a single channel
I am tring to calculate the average value of all the data points on a single plot between two seperate points
I have attahced an illustration.
Tim
Solved!
Go to Solution.
Attachments:
plot.jpg 173 KBHey smoothdurban,
I've seen Brad's code, and trust me, it's worth the effort to let him help you get it up and running - it's definitely the most ideal way to solve this problem. However, as Brad said, there are multiple ways to tackle this - both interactive and programmatic - so in the meantime, I'll take a second to detail one of the interactive and sure-fire ways to find the average of data between two points on a single channel.
We'll use"Flags." Set up your VIEW graph exactly as you did on your original screenshot, using Band Cursors to approximate the beginning and ending X-values representing the range you want to examine. Next:
1. Click the "Set Flags" button () that is a part of your 2D Axis System. Note that you can hold down the Shift button if you ever decide you want to do this on more than a single curve at one time.
2. Select the "Flags: Copy Data Points" button that enables after Flags are set.
3. This creates new channel(s) in the default (bold) group in the Data Portal that contains only the Flagged data.
4. Select DIAdem ANALYSIS.
5. Select Statistics » Descriptive Statistics.
6. In the Channels input, select the newly created channel containing your Flagged Y-Data.
7. Ensure that the Arithmetic Mean parameter is set. You can preview the data and the result in the dialog before pressing OK to execute the calculation.
You may have noticed that in the Descriptive Statistics calculation, one of the parameters that you can set is the range of channel rows to operate on - so, if you know the row numbers of your beginning and ending X-values, you could just simply run the Descriptive Statistics calculation and use this parameter to operate on a row subset of your original channel instead of the entire channel.
Derrick S.
Product Manager
NI DIAdem
National Instruments -
Finding unique minimum value from a set of values
Hi.
I have numbers in three columns - H, P, X
I need to compare numbers in each row and find out the lowest value and find out if there is a unique lowest value.
For example, in row 2
H2=2, P2=5.4, X2=2. In this row, both H2 and X2 have the lowest number, 2. Hence, the lowest number is not unique. I want to fill cells H2 and X2 in Yellow and cell P2 in Red.
In row 3,
H3=2, P3=5.4, X3=4. In this row, H3 has the lowest unique number, 2. I want to fill cell H3 in Green and cells P3 and X3 in Red.
Green = lowest and unique
Yellow = lowest but not unique
Red = Not the lowest
I can use the MIN function to find the least number but I do not know how to identify the unique lowest number if available.
Thanks for your help.Select for example H2:H100. I will assume that the active cell within the selection is in row 2.
Color the cells yellow (this will be the default)
On the Home tab of the ribbon, click Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter the formula
=OR($H2>$P2,$H2>$X2)
Click Format...
Activate the Fill tab and select red.
Click OK, then OK again.
On the Home tab of the ribbon, click Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter the formula
=AND($H2<$P2,$H2<$X2)
Click Format...
Activate the Fill tab and select green.
Click OK, then OK again.
The formulas for columns P and X are similar, switching the roles of the three cells.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Finding the minimum number greater than zero in an array
Hi All,
I have an Array (Attached). I need to find the minimum number that is NOT zero.
Using the Array Max & Min returns 0 as the min. What I want is the next minimum number.
Thank you.
D
Attachments:
Array.jpg 72 KBDo you also need the position of the found element? What if several numbers have the same minimum value?
If you just want the value of the smallest nonzero element, here's what I would do. All you neet to do is retain is a single number.
This assumes that your zeroes are really zero. With DBL you never know.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
SmallestNEZero.png 20 KB -
Finding the largest values of an array without using if condition
Hi,
I am trying to find the largest values of an array without using any if condition. Can any one tell me the solution for that..
ThanksI am trying to find the largest values of an arrayThe 'S' to values suggests that you want not only the largest one, but multiple ones among the largest ones. The best way, I think, is to sort the array, so that its largest values are grouped topgether. If the type is already Comparable, the following single line does the job:
Collections.sort(myArray);After this, the last values of the array are the largest ones.
Jerome. -
Hi team,
I have the following query where i need to find the max value
[code]
with t as (
select 'L1' R_nm ,'Data' R_Data , 'Obj' R_Obj , 'Wd' r_prec , '2' val from dual
union all
select 'L1' , 'Data', 'Obj' , 'No', '4' from dual
union all
select 'L2' , 'Data', 'Obj' , 'No', '4' from dual )
select t.*, max(val) over(partition by r_nm,r_data,r_obj) rk from t
[/code]
My expected output should be
[code]
r_nm r_data r_obj r_prec val rk
L1 Data Obj Wd 2 1
L1 Data Obj No 4 2
L2 Data Obj Yes 1 1
[/code]
Thank YouHi,
It looks like you're not interested in the MAX at all. It looks like you want to rank the rows, such that the one with the lowest value is assigned the number 1, the row with the 2nd lowest values gets 2, ..., and the row with the N-th lowest value gets N. If doesn't matter if the MAX is 4, or 2, or 420.
Here's one way to do that:
SELECT t.*
, RANK () OVER ( PARTITION BY r_nm, r_obj
ORDER BY val
) AS rk
FROM t
ORDER BY r_nm, r_obj
, val
Depending on how you want to deal with ties, you might want to use ROW_NUMBER or DENSE_RANK instead of RANK. -
Please - immediate help needed parsing csv values into multiple rows
Hello, we have a very immediate need to be able to parse out a field of comma separated values into individual rows. The following is an example written in SQL Server syntax which does not work in Oracle.
The tricky part is that each ROUTES can be a different length, and each CSV can have a different number of routes in it.
Here is an example of the table ("Quotes") of CSV values I want to normalize:
TPNUMBER ROUTES
1001 1, 56W, 18
1002 2, 16, 186, 28
Here is an example of what I need it to look like:
TPNUMBER ROUTES
1001 1
1001 56W
1001 18
1002 2
1002 16
1002 186
1002 28
Here is the "Tally" table for the query below:
ID
1
2
3
4
5
6
7
And finally, here is the query which parses CSV values into multiple rows but which does not work in Oralce:
SELECT TPNUMBER,
NullIf(SubString(',' + ROUTES + ',' , ID , CharIndex(',' , ',' + ROUTES + ',' , ID) - ID) , '') AS ONEROUTE
FROM Tally, Quotes
WHERE ID <= Len(',' + ROUTES + ',') AND SubString(',' + Phrase + ',' , ID - 1, 1) = ','
AND CharIndex(',' , ',' + ROUTES + ',' , ID) - ID > 0
It may be necessary to use a cursor to loop through the CSV table and process each row (a loop within another loop...) but this is beyond my comprehesion of PL/SQL.
Many thanks in advance for your advice/help.
apkNot sure what you are trying to do with the last step, but this should work for the first part. I assume you would use sqlldr but I just did inserts instead. You might need more than 5 "routes" in the csv. You could put some reasonable max on that number of columns:
SQL>create table t_csv
2 (TPNUMBER varchar2(20),
3 ROUTE_1 VARCHAR2(5),
4 ROUTE_2 VARCHAR2(5),
5 ROUTE_3 VARCHAR2(5),
6 ROUTE_4 VARCHAR2(5),
7 ROUTE_5 VARCHAR2(5),
8 ROUTE_6 VARCHAR2(5) );
Table created.
SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2) values( '1001 1', '56W', '18' );
1 row created.
SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2,ROUTE_3) values( '1002 2', '16', '186', '28');
1 row created.
SQL>create table t_quotes(
2 tpnumber NUMBER,
3 routes VARCHAR2(5));
Table created.
SQL>DECLARE
2 L_tpnumber NUMBER;
3 L_route VARCHAR2(5);
4 begin
5 for rec in (select * from t_csv) loop
6 L_tpnumber := SUBSTR(rec.tpnumber,1,INSTR(rec.tpnumber,' ')-1);
7 L_route := SUBSTR(rec.tpnumber,INSTR(rec.tpnumber,' ')+1);
8 insert into t_quotes values( L_tpnumber, l_route );
9 if rec.route_1 is not null then
10 insert into t_quotes values( L_tpnumber, rec.route_1 );
11 end if;
12 if rec.route_2 is not null then
13 insert into t_quotes values( L_tpnumber, rec.route_2 );
14 end if;
15 if rec.route_3 is not null then
16 insert into t_quotes values( L_tpnumber, rec.route_3 );
17 end if;
18 if rec.route_4 is not null then
19 insert into t_quotes values( L_tpnumber, rec.route_4 );
20 end if;
21 if rec.route_5 is not null then
22 insert into t_quotes values( L_tpnumber, rec.route_5 );
23 end if;
24 end loop;
25 end;
26 /
PL/SQL procedure successfully completed.
SQL> select tpnumber, routes from t_quotes;
TPNUMBER ROUTE
1001 1
1001 56W
1001 18
1002 2
1002 16
1002 186
1002 28
7 rows selected.
Maybe you are looking for
-
attached mini to my samsung 23" LCD hdtv via DVI cable. I get a picture but there is a black margin around the display. On boot up the display is full screen but reduces when OS is loaded. Display is currently 1280*860 (I think - I'm at work at the m
-
I'm due for new phone now. I use my old pearl blackberry phone for emails, web, and most importantly syncing my Microsoft Outlook contact, tasks, and calendar. I know the BB does it, but do these other Droids or other smartphone do it? The Blackbe
-
File sender adapter: archiving not possible with transp.prot "filesystem,
Hi XI gurus, in my FILE sender adapter I want to archive the processed files to a separate sub-directory of the "in" directory. It works if I use transport protocoll "FTP" with a specific user but it don't works when I use transport protocoll "file s
-
Exchange Rate difference in MIRO
Hi, A Import PO made at 63.52/EURO and Exchange rate Fixed not ticked. When i do the MIRO,the exchange rate shows as 56.9/EURO and the field is greyed out. How the Invoice can be posted and where the differnce will go. Is there any configuration for
-
I photo . When trying to go to full screen it goes fuzzy, Does not happen in film show. Help Please!