How to propogate previous row value
All,
I have a query were I need to fill the null data with previous row value. Like I have a table were we record all the On hand quantity for a item for a date. Lets say I have only 2 rows in this table for a month then I am planning to write a view that will give me 31/30 rows for a month and if for a specific date is the value is null then it should read from previous row unitl it finds the data otherwise display 0.
Ex. Actual table
Item No Date Qty
1 1/1/2010 10
1 1/5/2010 15
View I have written, I need to fill the null Qty with previous row data
Item No Date Qty
1 1/1/2010 10
1 1/2/2010
1 1/3/2010
1 1/4/2010
1 1/5/2010 15
1 1/6/2010
I want something like this how can i do this?
Item No Date Qty
1 1/1/2010 10
1 1/2/2010 10
1 1/3/2010 10
1 1/4/2010 10
1 1/5/2010 15
1 1/6/2010 15
Thanks
Hi Sung, sorry by my delay
Basically I'm building a Client Framework that a lot of actions are automatically managed, then I extend Objects
for example EntityImpl. I let to user set any value to the
database mapped fields but I will check this values
using my own bussines rules before to insert into database
and if this values are wrong I display an alert.
My problem is that I catch insert event to call validate
functions. But when any value is wrong I will show an alert, but if user commits transaction after validate
funcion is not revalidated. Well I supose that is a bad implementation for validation rules, now amb reading about
Validationlistener because I think is the best way to do
all that I need. I let to the user add field values but
these values not will commited while validationListeners
return isValid = true;
Thanks Sung.
Albert.
Similar Messages
-
How to display first row value returened from a query as checked as default in a report
How to display first row value returned from a query as checked as default in a report
Example
Parameter 1
Paramerter2
ABD
x(checked)
Test
DEF
JMG
MudassarHi Mudassar,
The issue is caused by the order in which the parameters appear in the report data tab can be difference between our report execution and it failing. In other words, “Parameter2” is execution before parameter “A” due to this issue. We can adjust the parameter’s
order to solve the issue.
If “Parameter2” is parameter “A”, we cannot use that expression. Because fields cannot be used in report parameter expression, if we want to display the first value returned from a query as default value, we have to fill the “Specify values” text box with
the specific value in Default Values dialog box.
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support -
How to capture the row value in Advanced Table on OAF ?
Hi:
I was wondering, if anyone has any idea as to how to capture a row value on an advanced table on a OAF Page.
I am currently trying to capture the Expense Report Number ( first column) on the Track Expenses Reports table on the page /oracle/apps/ap/oie/webui/HomePG.
Any idea would be helpful ?
Thank YouHi,
856070 wrote:
This is what I am looking for :
Default Functionality
On the expenses home page there is a table for the Submitted expenses Table ( advanced table) with multiple Expense Number rows , which has a link associated with every expense number. When the user clicks the expense number link , EBS takes you to a more detail information page. ---As per default functionality :::whene ever user clicks on link it will takes u to details info page based expense no right.
---Check the property of the Destination URL of the ExpensionNumber column.
---In this property u can find the page path and paramam ex:pexpencenumber.
Customized functionality
I would like to capture the Expense number on the detailed page to call another application based on the expense number. The expense number on the
detailed page is not available on the request-parameter or on the VO.
I was thinking of capturing the ExpenseNumber when the user clicks it and save the expense number on a >transientvalue to retrieve it on the detaile dpage..but unable to do so.---Here get the paramereter pexpencenumber and pass it to another appilcation.
Regards
Meher Irk -
Compare previous row values for the same id and decide
Hello ,
I have this sample data
create table #student_academic
pk_id int identity(1,1) primary key ,
student_id int ,
[year] int,
[aggr_marks] float
insert into #student_academic
student_id ,
[year] ,
[aggr_marks]
values
(112,2012,55.4),(113,2012,65.4),(114,2012,82.32),
(112,2013,75.4),(113,2013,91.22),(114,2013,45.45),
(112,2014,61.2),(113,2014,95.2),(114,2014,75.6)
select * from #student_academic
from the above data i have to generate an extra status column. this status column should be decided by comparing the previous row value. the exact output should be like below.
student_id year aggr_marks Staus----------------------------------------------------------
112 2012 55.4 None
112 2013 75.4 Promoted
112 2014 61.2 Demoted
113 2012 95.2 None
113 2013 75.6 Demoted
113 2014 91.22 Promoted
113 2012 45.45 None
113 2013 65.4 Promoted
113 2014 82.32 Promoted
is there any way to write the t-sql with out using cursors ? this table has around 25GB of data. Any idea would be appreciated.
Thanks in advance.Hello,
The difficulty of your example is
that there are several rows for
the same year and the same student.
I present a solution
if there is
one line per year per
student:
TRUNCATE TABLE #student_academicinsert into #student_academic
student_id ,
[year] ,
[aggr_marks]
values
(112,2012,55.4),(113,2012,65.4),(114,2012,82.32),
(112,2013,75.4),(113,2013,91.22),(114,2013,45.45),
(112,2014,61.2),(113,2014,95.2),(114,2014,75.6)
Go
WITH CTE AS
(SELECT pk_id, student_id, year, aggr_marks,
(SELECT TOP 1 aggr_marks FROM #student_academic AS b
WHERE a.student_id = b.student_id AND a.year -1 = b.year
ORDER BY student_id) AS prev_aggr_marks
FROM #student_academic AS a
SELECT
pk_id, student_id, year, aggr_marks,
CASE
WHEN prev_aggr_marks IS NULL THEN 'None'
WHEN aggr_marks < prev_aggr_marks THEN 'Demoted'
WHEN aggr_marks >= prev_aggr_marks THEN 'Promoted'
END AS Status
FROM CTE
ORDER BY student_id, year
Regards,
Charlie
Charlie Dancoisne - Independent Consultant & Trainer (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable. This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!) -
Urgent SQL question : how to flip vertical row values to horizontal ?
Hello, Oracle people !
I have an urgent SQL question : (simple for you)
using SELECT statement, how to convert vertical row values to horizontal ?
For example :
(Given result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1
K. Smith ...............1
K. Smith ........................1
(Needed result-set)
MANAGER COLUMN1 COLUMN2 COLUMN3
K. Smith ......1 .......1 .......1
I know you can, just don't remeber how and can't find exactly answer I'm looking for. Probably using some analytic SQL function (CAST OVER, PARTITION BY, etc.)
Please Help !!!
Thanx !
Steve.scott@ORA92> column vice_president format a30
scott@ORA92> SELECT f.VICE_PRESIDENT, A.DAYS_5, B.DAYS_10, C.DAYS_20, D.DAYS_30, E.DAYS_40
2 FROM (select t2.*,
3 row_number () over
4 (partition by vice_president
5 order by days_5, days_10, days_20, days_30, days_40) rn
6 from t2) f,
7 (SELECT T2.*,
8 row_number () over (partition by vice_president order by days_5) RN
9 FROM T2 WHERE DAYS_5 IS NOT NULL) A,
10 (SELECT T2.*,
11 row_number () over (partition by vice_president order by days_10) RN
12 FROM T2 WHERE DAYS_10 IS NOT NULL) B,
13 (SELECT T2.*,
14 row_number () over (partition by vice_president order by days_20) RN
15 FROM T2 WHERE DAYS_20 IS NOT NULL) C,
16 (SELECT T2.*,
17 row_number () over (partition by vice_president order by days_30) RN
18 FROM T2 WHERE DAYS_30 IS NOT NULL) D,
19 (SELECT T2.*,
20 row_number () over (partition by vice_president order by days_40) RN
21 FROM T2 WHERE DAYS_40 IS NOT NULL) E
22 WHERE f.VICE_PRESIDENT = A.VICE_PRESIDENT (+)
23 AND f.VICE_PRESIDENT = B.VICE_PRESIDENT (+)
24 AND f.VICE_PRESIDENT = C.VICE_PRESIDENT (+)
25 AND f.VICE_PRESIDENT = D.VICE_PRESIDENT (+)
26 AND f.VICE_PRESIDENT = E.VICE_PRESIDENT (+)
27 AND f.RN = A.RN (+)
28 AND f.RN = B.RN (+)
29 AND f.RN = C.RN (+)
30 AND f.RN = D.RN (+)
31 AND f.RN = E.RN (+)
32 and (a.days_5 is not null
33 or b.days_10 is not null
34 or c.days_20 is not null
35 or d.days_30 is not null
36 or e.days_40 is not null)
37 /
VICE_PRESIDENT DAYS_5 DAYS_10 DAYS_20 DAYS_30 DAYS_40
Fedele Mark 35473 35209
Fedele Mark 35479 35258
Schultz Christine 35700
South John 35253
Stack Kevin 35701 35604 35402 35115
Stack Kevin 35705 35635 35415 35156
Stack Kevin 35706 35642 35472 35295
Stack Kevin 35707 35666 35477
Stack Kevin 35667 35480
Stack Kevin 35686
Unknown 35817 35698 35596 35363 35006
Unknown 35702 35597 35365 35149
Unknown 35724 35599 35370 35155
Unknown 35600 35413 35344
Unknown 35601 35451 35345
Unknown 35602 35467
Unknown 35603 35468
Unknown 35607 35475
Unknown 35643 35508
Unknown 35644
Unknown 35669
Unknown 35684
Walmsley Brian 35725 35598
23 rows selected. -
DAX - how to use dax to return a previous row value?
Hi,
I was trying to use the EARLIER function but couldn't make it work:
EVALUATE
SUMMARIZE (
CALCULATETABLE (
'Inscricoes',
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO] <= VALUE(26),
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO] > VALUE(26) - 5,
'Escola'[ID_TB_DIM_UNIDADE_ORGANICA] = VALUE(6),
Curso[ID_TB_DIM_CURSO] = VALUE(372),
'Tipo de Inscricao no Curso'[DS_TIPO_INSCRICAO_CURSO]
= "Matrícula"
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO],
'Ano Letivo'[DS_ANO_LETIVO],
"NR_INSCRICOES", [NR_ESTUDANTES_INSCRITOS])
This generates:
ID_TB_DIM_ANO_LETIVO
DS_ANO_LETIVO
NR_INSCRICOES
22
2010-11
93
23
2011-12
101
24
2012-13
84
25
2013-14
85
26
2014-15
104
I need a new field that does returns the previous value of subscriptions (NR_INSCRICOES), so last 2 columns will be:
93 -
101 - 93
84 - 101
85 - 84
104 - 85
Need some help. ThanksHi Pedro,
According to your description, you want to get the previous row data along with each row. Right?
In DAX, we can use EARLIER() function to achieve this requirement. Please refer to link below:
PowerPivot DAX Session Notes 2 – Previous Row
In this scenario, I suggest you select the three columns into one table(let's say TABLE1). Then you can try the expression below:
=CALCULATE(MAX(TABLE1[NR_ESTUDANTES_INSCRITOS]), (FILTER(TABLE1,EARLIER(TABLE1[ID_TB_DIM_ANO_LETIVO])>TABLE1[ID_TB_DIM_ANO_LETIVO])))
Reference:
EARLIER Function (DAX)
Best Regards,
Simon Hou
TechNet Community Support -
How to copy existing row value into new row with a trigger. Same table
Oracle guru,
I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
-Oracle 10g express
-I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
-Table is composed of column like id,timestamps,A,B and more.
Thanks in advance
Pierre957911 wrote:
Oracle guru,
I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
-Oracle 10g express
-I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
-Table is composed of column like id,timestamps,A,B and more.
Thanks in advance
PierreI will call it a very Wrong design.
It is a wrong Table Design. You are duplicating the data in table and not complying with the Database Normalization rules.
How about Verifying if Column A & B are NULL before inserting and inserting another row and avoiding it in Triggers?
If you are bent to achieve this, below code might be helpful. However, I would never go with this approach. If you would care about explaining the reason for going ahead with such a data model, people could suggest better alternative that might conform with Normalization rules.
create or replace trigger trg_test_table
after insert on test_table
for each row
declare
pragma autonomous_transaction;
begin
if :new.col_a is null and :new.col_b is null then
insert into test_table
select 2, systimestamp, col_a, col_b
from test_table
where pk_col = (select max(pk_col) from test_table b where b.pk_col < :new.pk_col);
end if;
commit;
end trg_test_table;Read SQL and PL/SQL FAQ and post the mentioned details.
Do not forget to mention output from
select * from v$version; -
How to get previous row of result set in select query?
I want to access the previous row of an result set obtained yet, in the same selectquery .
How can I do that?Use analytical functions.
For example:
create table top_n_test (
a number,
b varchar2(10)
insert into top_n_test values (1, 'one');
insert into top_n_test values (2, 'two');
insert into top_n_test values (3, 'three');
insert into top_n_test values (4, 'four');
insert into top_n_test values (5, 'five');
insert into top_n_test values (6, 'six');
insert into top_n_test values (7, 'seven');
insert into top_n_test values (8, 'eight');
insert into top_n_test values (9, 'nine');
commit;
select a, b from (
select
a,b,
rank() over (order by b) r
from
top_n_test
where
r<4;
A B
8 eight
5 five
4 fourHTH
Ghulam -
How to get current row value from table when press the submit button
Hi,
I want to get the current row value of SuccessionPlanId which is one of the column in a advanced table.
I created one button (created using personalization, action fired thru CO)in the table as column, so each row having one button, if i press the first row's button means then i want to fetch the first row's SuccessionPlanId and if it is 3rd means then i want to get the value of third row's value.
How to do it in controller extension?
Please reply soon, its urgent.
Thanks in advance,
SANPratap,
Yes, I tried with 'delete' button which is seeded one.
For this, our code using row reference is working too fine. it throws exact SuccessionPlanId value of corresponding row.
I created MessageStyledText, but here i need to give text value right, then only it 'll appear in the page.
Instead i created one image and fired explicitly from the controller processRequest method.
But the same problem remains..
here my code:
public void processRequest(OAPageContext pageContext, OAWebBean webBean){
super.processRequest(pageContext, webBean);
OAButtonBean oabb = (OAButtonBean)webBean.findChildRecursive("XXSubmit");
FireAction action = new FireAction("XXSubmit");
oabb.setAttributeValue(UIConstants.PRIMARY_CLIENT_ACTION_ATTR, action);
OAImageBean oaib=(OAImageBean)webBean.findChildRecursive("XXSubmitImage");
oaib.setFireActionForSubmit("XXSubmitImage", null, null, true);
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean){
if("XXSubmitImage".equals(pageContext.getParameter("event"))){
String succIdI="";
String rowRefI = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
if(rowRefI != null && !("".equalsIgnoreCase(rowRefI ))){
PerSuccPlanSearchVORowImpl rowI = (PerSuccPlanSearchVORowImpl)oaam.findRowByRef(rowRefI);
if(rowI != null)
succIdI=rowI.getAttribute("SuccessionPlanId").toString();
}else{
throw new OAException("Row is null");
throw new OAException(succIdI, OAException.INFORMATION);
}else{
super.processFormRequest(pageContext, webBean);
If i run the page using this controller, it throws exception without any value, because for 'succIdI' i initialized without any string.
Can you please suggest me how to solve? -
How to convert a row value in CSV file to column value
Hi
We have one requirement where we have to show the row value to column level value
for Example:
Source file will be in below format
Component Name :101
**Batch # **100% Mod 200% Mod 300% Mod 400% Mod Tensile Elongation Thickness*
8584-17 498 1211 1986 2601 3133 523 0.088
Output Format has to be:
**Batch # **100% Mod 200% Mod 300% Mod 400% Mod Tensile Elongation Thickness Component name*
8584-17 498 1211 1986 2601 3133 523 0.088 101
How can we achieve this using shell/Perl script.
-
Compounding using previous row values
Greetings!
Im trying to write SQL in Oracle 10.2.0.4. I have no success using OVER , PARTITION analytic functions. Can someone help with this requirement..
Data :
with t as (select 1 AS Calc_Seq, 700 as erncd, 0.05 as pct, 22 Hrly from dual union all
select 2, 701, 0.05 , 22 from dual union all
select 3, 702, 0.075 , 22 from dual)
SELECT T.Calc_Seq,T.erncd,T.pct,T.hrly FROM T;
Output required as follows ...
Need compounded rate field, as PCT rate of previous row "Compounded rate" field value.
CALC_SEQ ERNCD PCT HRLY Compounded rate
1 700 0.05 22 23.1
2 701 0.05 22 24.255
3 702 0.075 22 26.074125Thanks in advance.
Edited by: Rama on Jan 9, 2013 11:39 AM
Edited by: Rama on Jan 9, 2013 11:50 AMHi,
Try this:
WITH
t AS
SELECT 1 AS Calc_Seq ,700 AS erncd ,0.05 AS pct ,22 Hrly FROM dual UNION ALL
SELECT 2 ,701 ,0.05 ,22 FROM dual UNION ALL
SELECT 3 ,702 ,0.075 ,22 FROM dual
SELECT
FROM
T
model
dimension by (calc_seq)
measures (erncd, pct, hrly, 0 cr)
rules
cr[any] order by calc_seq = case when cv(calc_seq) = 1 then hrly[cv(calc_seq) ] * (1 +pct[cv(calc_seq)])
else cr[ cv() -1] * (1 + pct[cv()]) end
CALC_SEQ ERNCD PCT HRLY CR
1 700 0.05 22 23.1
2 701 0.05 22 24.255
3 702 0.075 22 26.074125 Regards,
Peter -
Bulk collect seems to retain previous row value when current returns null
Dear all,
I am currently writing package in plsql.
The main logic of the program is as follow .. Program works fine .. but ... when no data is found for current V_1, V_2,V_3 , insertion is done with previous cursor row value of V_1,V_2,V_3, ... which is not good.
I tried to change the last nested cursor with first..last instead of 1..count, but result is the same.
Any idea?
open c_trt;
loop
fetch c_trt bulk collect into bk_trig limit v_limit;
open c_bkeve;
fetch c_bkeve bulk collect into bk_eve limit v_limit;
if bk_eve.count > 0 then
for k in 1..bk_eve.count loop;
case
when a =1 then
open c_bkieve(bk_eve(k).age,bk_eve(k).ope, bk_eve(k).eve);
fetch c_bkieve bulk collect into bk_ieve limit v_limit;
if bk_ieve.count > 0 then
for j in 1..bk_ieve.count loop
fetch c_bkieve bulk collect into bk_ieve limit v_limit;
if bk_ieve.count > 0 then
for j in 1..bk_ieve.count loop
case bk_ieve(j).a
when 'ABC' then
V_1 := nvl(trim(bk_ieve(j).b),null);
when 'XYZ' then
V_2 := nvl(trim(substr(bk_ieve(j).b,1,4)),null);
V_3 := nvl(trim(substr(bk_ieve(j).b,6,22)),null);
else
null;
end case;
end loop;
else
V_1 := null;
V_2 := null;
V_3 := null;
end if;
close c_bkieve;
insert into xxx values(V_1,V_2,V_3);
etc, etc
Thanks for your help
JeromeSomething like this
select a.dco
, a.agsa
, a.agem
, a.agde
, a.ope
, a.eve
, a.tpr
, a.nat
, a.age
, a.dev
, a.ncp
, a.suf
, a.sen
, a.dva
, a.mon
, a.lib
, c.cli
from bmvtg_mi a
join bcom c
on a.age = c.age
and a.dev = c.dev
and a.ncp = c.ncp
and a.suf = c.suf
join (
select x.*
, y.cur_char
from bkeve_mi x
left join wb_currency y
on x.csp4 = y.cur_num
) b
on b.age = decode(v_var1, 'age', a.age, 'agem', a.agem, 'agsa', a.agsa, 'agde', a.agde, a.age)
where exists
select *
from wb_client sc
where c.cli = sc.customer_number
and ready = 1
and exists
select *
from wb_pdt sp
where c.cpro = sp.c_pro -
How to access each row value for a database item
On my form I have a database datablock that represents a table in my database.
5 rows are shown with a scroll bar that can be viewed to show the rest.
The user is able to change some of the Database Item values represented in this datablock for any row shown in the datablock.
I need to validate the correctness of the users change before allowing the database datablock to update the table in the database.
But a database item in a datablock will represent a value for every row in the table. So how do I access each row value for a database item separately. What is the PL/SQL syntax?
thanks,
michelleIn my situation it was better to use the loop instead
of a when validate trigger because...Well it was clearly not better to use a loop that doesn't work. I don't understand what you're not clear on about the item and record validation triggers. If you have a specific validation rule for a single field (such as a date that cannot be in the future), that would go in a When-Validate-Item trigger on the date item. If the user enters a future date, your code would display an error message and raise a failure. Raising a failure prevents the item from being marked as valid. Invalid items prevent the record from being inserted/updated. Sometimes you have a validation rule that requires looking at more than one item at a time, such as two items that must either both be NULL or NOT NULL. In that case, you could not use a When-Validate-Item trigger because you can't clear or populate both at once. So then you would use a When-Validate-Record at the block level and if one field is NULL and the other isn't, you would display an error message and raise a failure. Forms is very civil in this respect; we don't throw exceptions around here, but then I digress. -
How to get Current Row values in Af:ForEach
Hi,
We have a requirement to conditionally Display/Hide CommandLink item in af:forEach Loop.
<af:forEach items="#{bindings.RegionalAreaPVO.rangeSet}" var="parent">
<af:spacer height="10" id="s1"/>
<af:commandLink inlineStyle="font-weight:bold;" text="#{parent.ItemName}" partialSubmit="true" actionListener="#{backingBeanScope.RegionalAreaBean.launchTaskflow}" id="cl1" rendered="*#{backingBeanScope.XXWFCRegionalAreaBean.modelEligibleflag eq true}*">
<af:setActionListener from="#{parent.Code}" to="#{parentNode}"/>
</af:commandLink>
</af:forEach>
I have added a Cutom Managed Bean Class and Returning boolean value to Control Render property which is working. But now i want to add business Logic based on 'parent.ItemName' or 'parentNode' Values in the bean method to return proper Boolean value.
But i am unable to get the Current Iteration values in the bean method.
I am using below EL expressions to get the values. But no luck.
String nameel = (String)ADFUtil.evaluateEL("#{bindings.parent.ItemName}");
String codeel = (String)ADFUtil.evaluateEL("#{parent.Code}");
String nodeEl = (String)ADFUtil.evaluateEL("#{parentNode}");
Also, i have tried getting the Row object like below but i am getting the First row details always. My intention is to get Current row values and use them for Business logic.
ViewRowImpl row =
(ViewRowImpl)ADFUtil.evaluateEL("#{bindings." + VoName +
"Iterator.currentRow}");
String code = (String)row.getAttribute("Code");
Any help is highly appreciated.
Thanks
KajaHi Sascha,
I have tried that. But in my case the functional logic behind the Rendering is based on more complex logic. Hence i am trying to add a method to return a boolean in Render property of the Link.
But the real problem for me is, in the Managed bean method i am not finding a way to get the Current Iteration index. If i can get the Current iteration index, i can get the Corresponding Component ID of Command link (In the forEach Loop Component Id's are getting generated Dynamically based on Iteration Index), i can use that and add additional logic and derive true/false to return.
Any inputs?
Thanks
Kaja -
How to convert some row values in columns
Hello guys,
I'm using Oracle 10g in a windows platform, I have the following data:
with test as
select '000-ME-001' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
select '000-ME-001' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
select '000-ME-001' tag_number, 'Capacity 350' tag_details1, '000-TS-M-228' tag_details2 from dual union all
select '000-ME-002' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
select '000-ME-002' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
select '000-ME-002' tag_number, 'Capacity 350' tag_details1, '000-TS-M-228' tag_details2 from dual union all
select '000-ME-003' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
select '000-ME-003' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
select '000-ME-003' tag_number, 'Capacity 350' tag_details1, '' tag_details2 from dual
)How can I covert the values of tag_details1 as column name to achieve this result:
tag_number Capacity 150 Capacity 250 Capacity 350
000-ME-001 000-TS-M-226 000-TS-M-227 000-TS-M-228
000-ME-002 000-TS-M-226 000-TS-M-227 000-TS-M-228
000-ME-003 000-TS-M-226 000-TS-M-227Hope you can help me, best regards.select tag_number
, max (decode (tag_details1, 'Capacity 150', tag_details2))
, max (decode (tag_details1, 'Capacity 250', tag_details2))
, max (decode (tag_details1, 'Capacity 350', tag_details2))
from test
group by tag_numberas in
SQL> with test as
2 (
3 select '000-ME-001' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
4 select '000-ME-001' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
5 select '000-ME-001' tag_number, 'Capacity 350' tag_details1, '000-TS-M-228' tag_details2 from dual union all
6 select '000-ME-002' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
7 select '000-ME-002' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
8 select '000-ME-002' tag_number, 'Capacity 350' tag_details1, '000-TS-M-228' tag_details2 from dual union all
9 select '000-ME-003' tag_number, 'Capacity 150' tag_details1, '000-TS-M-226' tag_details2 from dual union all
10 select '000-ME-003' tag_number, 'Capacity 250' tag_details1, '000-TS-M-227' tag_details2 from dual union all
11 select '000-ME-003' tag_number, 'Capacity 350' tag_details1, '' tag_details2 from dual
12 )
13 select tag_number
14 , max (decode (tag_details1, 'Capacity 150', tag_details2))
15 , max (decode (tag_details1, 'Capacity 250', tag_details2))
16 , max (decode (tag_details1, 'Capacity 350', tag_details2))
17 from test
18 group by tag_number
19 /
TAG_NUMBER MAX(DECODE(T MAX(DECODE(T MAX(DECODE(T
000-ME-002 000-TS-M-226 000-TS-M-227 000-TS-M-228
000-ME-001 000-TS-M-226 000-TS-M-227 000-TS-M-228
000-ME-003 000-TS-M-226 000-TS-M-227Edited by: Alex Nuijten on Jun 3, 2009 4:03 PM
Maybe you are looking for
-
Here is an interesting one. I am using Safari 2.0.4 and have done a bit of customizing. One thing that happens is that every once in a while Safari will add bookmarks that I had thrown out. It has added eBay, Amazon and Yahoo to my bookmark bar. Also
-
Business content activation in a fresh implementation
Dear Gurus Before i begin let me state that i did check and did get information about activation...my concern is that i am new to implementation and i want to know exactly what are the steps that need to be followed at R3 end and in BI when we imlpe
-
Hardware buffering not working on Win XP Pro
Card: Audigy 2 Platinum with latest drivers (02.09.006) Latest DirectX 9.0c (directx_dec2006_redist.exe) DxDiag DirectSound test passes ok, except that at the end gives: "Your card does not support hardware buffering. Sounds will only play back from
-
How to remove update notification?
How to remove the update notification as it shown '1' at the top of app store icon? I was asked to update 'facebook' but then it requires my friend's id password instead of mine.. I've signed out all of his data from my iphone, but still can't be upd
-
Why logical partition is a must for voting disk and OCR
Hi Guys, I just started handling jobs for RAC installation, I have a simple question regarding the setup. Why does logical partition have to be used for voting disk and OCR? I tried partition the disk that were provisioned for voting disk and OCR wit