Problem in displaying row vale as column name
Hello Experts,
Please help me,its very urgent....
i want to dispaly a column value as a column name.
i have two column into selete statement and i want to dispaly one column value as a column name and other column value as a single row.
My query is :
SELECT MAX(DECODE (NAME,'virtualDeviceId',VALUE))vdid ,
MAX(DECODE (NAME,'virtualDeviceType',VALUE)) vdevtype,
MAX(DECODE (NAME,'domainName',VALUE)) vdevtype1,
MAX(DECODE (NAME,'sCTPPortSip',VALUE)) vdevtype2,
MAX(DECODE (NAME,'signallingIpAddress',VALUE)) vdevtype,
MAX(DECODE (NAME,'signallingNetworkMask',VALUE)) vdevtype,
MAX(DECODE (NAME,'uDPPort',VALUE)) vdevtype,
MAX(DECODE (NAME,'uDPPortEnum',VALUE)) vdevtype,
MAX(DECODE (NAME,'sCTPPort',VALUE)) vdevtype,
MAX(DECODE (NAME,'sCTPPortM3UA',VALUE)) vdevtype FROM(
SELECT extractvalue(VALUE(l),'/S109:trafficParameters/S109:name'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') NAME,
extractvalue(VALUE(l),'/S109:trafficParameters/S109:value'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') VALUE
FROM INTERFACE_MESSAGE_DESTINATION imd ,TABLE(xmlsequence(EXTRACT(XMLTYPE(imd.remote_request),'/activateConnection_Payload/jobBody/subnetworkConnection/S109:aEndTerminationPoint/S109:managedElement/S109:physicalTerminationPoint/S109:connectionTerminationPoint/S109:trafficDescriptor/*'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"'))) l
WHERE message_id ='NIAS/0000041608') GROUP BY VALUE ;
output is :
Col1 Col2 col3 col4 col5 col
1.'1001105' '1001105'
2. 'MGC'
3.'value' 'value' 'value'
output display : MGC in Col2 and in row 2, 'values' are in col4 and col5 and in row 3.
I want all values in a single row.
Please help me
Surender Rana
It is ugly to force multiple rows into a single row. But it can be done and can be done dynamically as the following approach shows.
SQL> create or replace type TStrings as table of varchar2(4000);
2 /
Type created.
SQL>
SQL> create or replace function ForceColumns( cur SYS_REFCURSOR ) return TStrings is
2 setCols TStrings;
3 setResults TSTrings;
4 begin
5 setResults := new TStrings();
6 loop
7 fetch cur into setCols;
8 exit when cur%NOTFOUND;
9
10 if setCols.Count > 0 then
11 setResults.Extend( setCols.Count );
12 for i in 1..setCols.Count
13 loop
14 setResults( setResults.Count-i+1 ) := setCols(i);
15 end loop;
16 end if;
17 end loop;
18
19 return(setResults);
20 end;
21 /
Function created.
SQL>
SQL> select
2 ForceColumns(
3 CURSOR(
4 select TStrings(object_id,object_name,object_type) from user_objects where rownum <= 5
5 )
6 ) as RESULT_SET
7 from dual
8 /
RESULT_SET
TSTRINGS('TABLE', 'A', '70998',
'PROCEDURE', 'ABC', '54360',
'TABLE', 'ANIMALS', '84829',
'TABLE', 'B', '69604',
'PROCEDURE', 'BUILDNAMEMAP', '70155')
SQL>Note that as the row can contain any number of columns, it needs to be dynamic. This approach uses a collection type called TStrings to achieve this.
Similar Messages
-
Changing rows into different column names
Hi,
i need to tranpose the rows into differnent column names
my sample data :
id , val
1 3
1 4
1 5
into
id , val1, val2 , val3 , val4 ... valn ..
1 3 4 5
from askTom's i see that it's tranpose into a single column using the ref cursor ?
how can i do made it into different column names ?
kindly advise
tks & rdgsFor example, lets say that you want to order your columns from least value to greatest and that you'll never have more than three values per id. Then you can use the analytic function row_number() like this to create a pivot value.
select id, val,
row_number() over (partition by id order by val) as rn
from your_table;And so your pivot query ends up looking like this.
select id,
max(case when rn=1 then val end) AS val1,
max(case when rn=2 then val end) AS val2,
max(case when rn=3 then val end) AS val3
from (
select id, val,
row_number() over (partition by id order by val) as rn
from your_table
group by id;But notice that I started out by making up answers to Justin's questions. You'll have to supply the real answers. -
Supplying row value as column name
Hi all,
I have two tables in which row value in one table is column name of other. How do i relate it to retreive the data...
Table 1: control (contains 3 columns in it)
table_name - parametername - parametervalue
MI - UNPROCESSED_FLAG - N
MI - PROCESSED_FLAG - Y
MI - FROM_DATE - 01-JAN-2008
MI - TO_DATE - 31-DEC-2010
EMP - DEPTNO - 30
EMP - JOB - SALESMAN
EMP - FROM_DATE - 01-JAN-1982
EMP - TO_DATE - 31-DEC-1995
Table 2: emp (contains the columns: empno,ename,deptno,job,hiredate)
I want to display all details from emp table according to the parameter given in control table. I have already written a query using subquery
select *
from emp
where
deptno = (select parameter_value from job_control where parameter_name = 'DEPTNO')
and
job = (select parameter_value from job_control where parameter_name = 'JOB')
and
hiredate between (select parameter_value from job_control where parameter_name = 'FROM_DATE' and table_name = 'EMP') and (select parameter_value from job_control where parameter_name = 'TO_DATE' and table_name = 'EMP');
But i want to write ot using joins. Plz help me out.....
ThanksHi,
Welcome to the forum!
Whenever you have a question, please post CREATE TABLE and INSERT statements for your sample data, so that the people who want to help you can re-create the problem and test their ideas. (There's no need to post commonly available tables. like those in the scott schema, but make it clear which such tables you're using.) Since this is your first post, I'll do it for you:
CREATE TABLE control_table
table_name VARCHAR2 (20)
, parametername VARCHAR2 (20)
, parametervalue VARCHAR2 (20)
INSERT INTO control_table (table_name, parametername, parametervalue) VALUES ('EMP', 'DEPTNO', '30');
INSERT INTO control_table (table_name, parametername, parametervalue) VALUES ('EMP', 'JOB', 'SALESMAN');
INSERT INTO control_table (table_name, parametername, parametervalue) VALUES ('EMP', 'FROM_DATE', '01-SEP-1981');
INSERT INTO control_table (table_name, parametername, parametervalue) VALUES ('EMP', 'TO_DATE', '31-DEC-1995');
INSERT INTO control_table (table_name, parametername, parametervalue) VALUES ('MI', 'FROM_DATE', '01-JAN-2008');
;Also post the exact results you want from that sample data. The query below produces these results from the control_table above and the standard scott.emp table:
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30Always say which version of Oracle you're using. The query below works in Oracle 9.1 and up.
One thing you can do is pivot the appropriate parameters into a one-row result set, and treat it as a table, like this:
WITH got_params AS
SELECT TO_NUMBER (MIN (CASE WHEN parametername = 'DEPTNO' THEN parametervalue END)) AS deptno
, MIN (CASE WHEN parametername = 'JOB' THEN parametervalue END) AS job
, TO_DATE (MIN (CASE WHEN parametername = 'FROM_DATE' THEN parametervalue END), 'DD-MON-YYYY') AS fromdate
, TO_DATE (MIN (CASE WHEN parametername = 'TO_DATE' THEN parametervalue END), 'DD-MON-YYYY') AS todate
FROM control_table
WHERE table_name = 'EMP'
SELECT e.*
FROM emp e
JOIN got_params p ON e.deptno = p.deptno
AND e.job = p.job
AND e.hiredate BETWEEN p.fromdate
AND p.todate
;This assumes that the combination (table_name, parametername) is unique in the control_table. -
Display rows into multiple columns
I have a table in the following format:
id value
a1 0
a2 0
a3 0
a4 0
b1 0
b2 0
b3 0
b4 0
how do I go about displaying it into four columns in the following format:
id1 value1 id2 value2
a1 0 b1 0
a2 0 b2 0
a3 0 b3 0
a4 0 b4 0Hi,
789063 wrote:
I got that error in toad. So now I am testing from command prompt. When you say "command prompt", do you mean SQL*Plus?
Sorry, I don't know much about Toad. If Toad is returning 0 rows, and the same query is returning 8 rows in SQL*Plus, then I suspect you are not connecting to the same database or the same user. ASre you sure you're running the exact same query in both front ends?
Here is the data set that I am testing for:
<pre>
id1 value
smple_val_1 0
smple_val_2 1
smple_val_3 1
smple_val_4 2
smple_other_1 3
smple_other_2 5
smple_other_3 8
smple_other_4 13
some_other_val1 1
some_other_val2 0
some_other_val3 3
some_other_val4 5
</pre>
I am trying to select only 'smple%' in the query, which should display in four columns like:
<pre>
id1 val1 id2 val2
smple_val_1 1 smple_other_1 3
smple_val_2 0 smple_other_2 5
smple_val_3 0 smple_other_3 8
smple_val_4 2 smple_other_4 13
</pre>Is that really the output you want? Why not
ID1 VAL1 ID2 VAL2
smple_val_1 0 smple_other_1 3
smple_val_2 1 smple_other_2 5
smple_val_3 1 smple_other_3 8
smple_val_4 2 smple_other_4 13with the 0's and 1's in the val1 column reversed?
Here is the ddl I used:
<pre>
CREATE TABLE table_x
( id VARCHAR2 (20) PRIMARY KEY
, value NUMBER
INSERT INTO table_x (id, value) VALUES ('smple_val_1', 0);
INSERT INTO table_x (id, value) VALUES ('smple_val_2', 1);
INSERT INTO table_x (id, value) VALUES ('smple_val_3', 1);
INSERT INTO table_x (id, value) VALUES ('smple_val_4', 2);
INSERT INTO table_x (id, value) VALUES ('smple_other_1', 3);
INSERT INTO table_x (id, value) VALUES ('smple_other_2', 5);
INSERT INTO table_x (id, value) VALUES ('smple_other_3', 8);
INSERT INTO table_x (id, value) VALUES ('smple_other_4', 13);
INSERT INTO table_x (id, value) VALUES ('some_other_val1', 1);
INSERT INTO table_x (id, value) VALUES ('some_other_val2', 0);
INSERT INTO table_x (id, value) VALUES ('some_other_val3', 3);
INSERT INTO table_x (id, value) VALUES ('some_other_val4', 5);
</pre>Thanks, that's good.
Where is the explanation of how you get the results you want from that data? There are a lot of different ways to get the same results from the same data, especially from a small set of sample data. I might provide a query that gets the right results for the wrong reasons, and when you run that query on a different set of data, it won't necessarily work. That's exactly what happened before. I guessed at what you wanted, but I guessed wrong. Guessing is not a very efficient or reliable way to solve problems. Don't make people guess: explain what you want.
In particular, explain how you can tell, buy looking at a row and column in the original table, to which row and which column of the output it corresponds. I'm pretty sure that the id column of the table always corresponds to either the id1 or idl2 column of the output, and that value always corresponds to either val1 or val2. From this latest set of sample data, it looks like all the rows in table_x that start with 'smple_val' will correspond to the id1 and val1 columns, and that all therows that start with 'smple_other_' will correspond to the id2 and val2 columns. It also looks like each row of the output represents a unique value of the last character of table_x.id.
If I guessed right this time, then what you want is:
SELECT MIN (CASE WHEN id LIKE 'smple\_val\_%' ESCAPE '\' THEN id END) AS id1
, MIN (CASE WHEN id LIKE 'smple\_val\_%' ESCAPE '\' THEN value END) AS val1
, MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN id END) AS id2
, MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN value END) AS val2
FROM table_x
GROUP BY SUBSTR (id, -1)
ORDER BY SUBSTR (id, -1)
;But this is only a guess. I can't guarrantee that this will work on your real data any better than my last guess did. You'll get better answers faster if you provide an explanation, so that poeple don't have to guess so much. -
Row Insert Failed - Column name or number of supplied values does not match
Hi ,
I am trying add a new field to an existing table in MSSQL and access it in portlets,
I added the new field in the table, and making necessary updations to the accessing java code seems to look fine. but when i insert the new rwo, fails with exception listed below.
My code tidbits is as follows.
System.out.println("Column Location of outsidePhysician"+ aResultSet.findColumn("outsidePhysician")); // works and returns 24
if (anIntake.getOutsidePhysician() != null && !(anIntake.getOutsidePhysician().equals("")))
System.out.println("Now Alternate Physician will be added to resultset");
aResultSet.updateString(24, anIntake.getOutsidePhysician());
aResultSet.updateString("outsidePhysician",anIntake.getOutsidePhysician());
System.out.println("Now Alternate Physician already added to resultset"); // also printed
}else{
aResultSet.updateString(24, "new Physician");
aResultSet.updateString("outsidePhysician","new Physician");
//NOT NULL
aResultSet.insertRow(); // fails here
System.out.println("Inserted");
The table has the right field name too, which is proved when i retrieve the fieldno, based on field name. I tried to delete the field and removing these changes work ok..
Any ideas would be of help
Thanks in Advance
Usha
[Microsoft][SQLServer 2000 Driver for JDBC]Row insert failed. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BaseImplUpdatableResultSet.executeStatement(Unknown Source) at com.microsoft.jdbc.base.BaseImplUpdatableResultSet.insertRow(Unknown Source) at com.microsoft.jdbc.base.BaseResultSet.insertRow(Unknown Source) at com.microsoft.jdbcx.base.BaseResultSetWrapper.insertRow(Unknown Source) at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.insertRow(WSJdbcResultSet.java:2181) ... 14 more Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Insert Error: Column name or number of supplied values does not match table definition. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceI haven't ever used that method of inserting rows, but from the example in the API documentation it looks to me like you have to callaResultSet.moveToInsertRow();before you callaResultSet.insertRow();Or are you just "inserting" the physician's name into existing rows of the database? If that's what you are doing then you need to callaResultSet.updateRow();Message was edited by:
DrClap -
Problem in displaying the data of columns into rows in sap script
hi,
i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
eg, C
12.1
Si
5.5
it is displaying the data right now like this but i want to display the data like this:-
eg, C Si
12.1 5.5
plzzprovide me guidelines how to solve this problem.hi,
i am using this code to display the data:-
plzz provide me guidelines where i am getting wrong?
TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
PROTECT
IF &I_FINAL-PRUEFLOS& NE '000000000000'
&I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ELSE
&I_FINAL-MAKTX(23)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ENDIF
ENDPROTECT
ITEMHEAD
POSITION WINDOW
SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
BOX FRAME 10 TW
BOX HEIGHT '1.35' LN INTENSITY 20
IF &PAGE& = '1'
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
For horizontal line at top
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
ELSE
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
ENDIF
LINEFEED
NEWPAGE
NEW-PAGE
provide me guidelines to solve this problem.
Edited by: ricx .s on Mar 13, 2009 5:58 AM -
ADF faces - Urgent! - problem in display row-detail
Hi all, I've maka a post yesterday but I still can't resolve the problem.
I have a page that display data from the database.
The amount of data is variable, so I configure the iterator as follow:
<methodIterator id="XLB_find_user_OLIter" Binds="XLB_find_user_OL.result"
DataControl="Session_EJB_TDBLocal" RangeSize="10"
BeanClass="TDB.model.OltdbView" Refresh="always"
CacheResults="false"/>
The table have a single selection column and a view detail button.
when user click the button, the following method is called (in the backing bean):
public String ElaboraAtt_action() {
OperationBinding bind=this.bindings.getOperationBinding("XLB_changeToWorkingOn_olTdb");
int ret=(Integer)bind.execute();
if(ret==0){
XLB_changeToWorkingOn_olTdb make some operation on the record and return a result code.
the bind for XLB_changeToWorkingOn_olTdb is:
<methodAction id="XLB_changeToWorkingOn_olTdb"
InstanceName="Session_EJB_TDBLocal.dataProvider"
DataControl="Session_EJB_TDBLocal"
MethodName="XLB_changeToWorkingOn_olTdb"
RequiresUpdateModel="true" Action="999"
ReturnName="Session_EJB_TDBLocal.methodResults.Session_EJB_TDBLocal_dataProvider_XLB_changeToWorkingOn_olTdb_result">
<NamedData NDName="username" NDValue="${userState.name}"
NDType="java.lang.String"/>
<NamedData NDName="callid" NDValue="${showOl_backing.currentCallid}"
NDType="java.lang.String"/>
</methodAction>
where showOl_backing is the backing bean.
In the backing bean, the code for current callid is:
public String getCurrentCallid() {
JUCtrlValueBindingRef tableRowRef=(JUCtrlValueBindingRef) this.getOl_table().getRowData();
return (String) tableRowRef.getRow().getAttribute("callid");
The problem is:
If the rows change between the rendered page and the next submit, the row retourned from getCurrentCallid() is wrong.
I've seen that, before start to execute the action, ADF refresh the table with the new values, so I think that the selection is made with an index, but on new values...
I've tried almous any solution...
Thanks!
Luca...ok...finally...I've done...
simply, i've setted cache resut to true in the iterator.
When af:pool refresh the table, or when a refresh button is click, a method call execute the operationBindings, and the result are refreshed...
Hi all! -
Problem in displaying rows using hGrid
Hi everyone,
I'm having diffilculties in creating hGrid
-> I have one table with columns Employe_number, Last_name, and Manager_id.
-> Created EO
-> Created VO and VL
I expect to retrieve a row similar to figure below
Lastname..........................................Emplno
Victor.............................................1
.....Rockwell......................................2
..........Ford.....................................21
...............Mel.................................211
.....Chan..........................................3
..........Madison..................................31But I only get the direct report
Lastname..........................................Emplno
Victor...............................................1
.....................................................2
.....................................................3People under Rockwell and Chan are not populated..
This is similar to tutorial's hGridPG but I gues I missed out something.
Appreciate for any help.
Thanks,
Elmer
Edited by: Elmer on Jan 30, 2010 12:13 AMHi everyone,
I was able to solve this problem. It's the value i put in the ancestor node.
From /oracle/apps/per/xxTree/webui/MainPG.TreeRN
To /sm/oracle/apps/per/xxTree/webui/MainPG.TreeRN
Elmer -
Problem in displaying rows in a table.
Hi
i have a query region and a results table .
i have a details button in results table which will fetch results in to the details table.
once i click the details button of a selected row i get the results into details table.
now the problem is after applying (commiting transaction) if i click on the another rows details button details table results are not changing..
what might be the problem...Hi,
i have a vendor name which is lov item.from there i will get the vendorid
In islovevent() i am capturing that value and passing the same to the initdetails in amimpl
which in turn calls initquery in voimpl
the problem is page details are refrshing fine if i dont add a row to the table .the problem arises only when i add a row...
when i add a row and try saving it.it saves properly. but when i go to vendor lov and selects another vendor ..the details are remianing same....
the code i used for above :
CO CODE:
if (pageContext.isLovEvent())
String lovInputSourceId = pageContext.getLovInputSourceId();
if ("SearchVendorName".equals(lovInputSourceId))
String vendorId=pageContext.getParameter("VendorIDfrm");
Serializable[] parameters={vendorId };
am.invokeMethod("initExemptionDetails",parameters);
AM CODE:
public void initExemptionDetails(String vendorid){
ExemptionVOImpl vo = getExemptionVO1();
if (vo == null) {
throw new OAException("CLE", "CLE_F272_VO_NULL");
vo.initExemptionQuery(vendorid);
VOIMPL CODE:
public void initExemptionQuery(String vendor_id){
setWhereClause(null);
reset();
setNamedWhereClauseParam("VENDOR_ID",Integer.parseInt(vendor_id));
executeQuery();
AND LAST BUT NOT LEAST WHICH IS CAUSING THE ERROR CODE FOR ADDING A ROW:
ExemptionVOImpl vo = getExemptionVO1();
if (vo != null)
vo.setMaxFetchSize(0);
vo.executeQuery();
Row row = vo.createRow();
if (vo.getFetchedRowCount() == 0)
vo.insertRow(row);
else
{ vo.insertRowAtRangeIndex(vo.getRowCountInRange(),row); }
vo.setCurrentRow(row);
row.setNewRowState(row.STATUS_INITIALIZED);
please help me out::: -
Need help in displaying Rows to Columns
Hi,
I am facing problem in displaying Rows to Columns
I am using pivot function:
select *
from
(select vendor_name
from tablea)
pivot
(count(vendor_name)
for vendor_name in ('a,b,'c'));
its working fine showing vendor_name and count
but when i want to display the output as:(How to include the Salalry column in the query?)
Name:{a b c}
Sal Total:(400,600,800}
Any help will be needful for meNot sure what you mean:
select *
from (select deptno,sal from emp)
pivot(sum(sal) for deptno in (10,20,30))
10 20 30
8750 10875 9400
SQL> SY. -
Transpose rows to columns with numeric column name
I am trying to transpose row to columns.
Here is my data having 3 columns (date, last_retry and count(*) )
Date last_retry count(*)
1/2/06 2 13
1/2/06 1 5
5/5/06 1 12
5/5/06 2 9
Desired Output with columns ( date, 1, 2)
Date 1 2
1/2/06 5 13
5/5/06 12 9
Here is my query which doesn't work
select trunc(Date),
max(Decode(last_retry,'1',count(*))) as 1,
max(Decode(last_retry,'2',count(*))) as 2
from retry_state
1st problem: How do I transpose if this is not correct?
2nd problem: 1 cannot be named as column name, how can I name the columns
3rd problem: Suppose I am selecting this data and loading into a table. Now can
the data be loaded during select as well as transposed at the same time or would I need to create a view to load the data first into table and then perform transpose?hi,
this will transpose your data and insert into the table:
INSERT INTO transposed_table
(SELECT my_date,
MAX(DECODE(last_retry,1,cnt,0)) AS "1",
MAX(DECODE(last_retry,2,cnt,0)) AS "2"
FROM retry_state
GROUP BY my_date)
note: to avoid problem and confusion, i renamed the fields DATE and COUNT(*) to MY_DATE and CNT respectively. You should avoid using reserved words as your fields such as DATE!
hope this helps. -
I want to display the patameters entered by the user as column names in interactive / classic report.
For example i enter the parameters as date, 10-03-2011, 11-03-2011 and 12-03-2011.
How i can display these dates as column names in report ?
SanjayIn a classic report, set the Headings Type (in the Report Attributes tab) to Custom and set the Heading to
&Px_PARAM1.
&Px_PARAM2.
&Px_PARAM3.
etc... -
Hi,
Is there a way to stop XMII from automatically converting the oracle column name "14_name_g/L" to "_14_name_g_L"? Or is there anything I can do to change it so that the right column name is displayed to the user?
I looked in the XML output of the query template in the BLS and the Column description is correct, but the column name gets automatically converted by XMII.
Additionally, I tried entering the column name "14_name_g/L" directly into an XML variable in a BLS transaction (as part of a valid xml document) and received the error: "Invalid XML String: The content of elements must consist of well-formed character data or markup.
I also tried converting the XMLOutput of the Query with an XSLT, but it didn't seem to work and if XMII won't accept the correct format in an XML variable I wasn't very optimistic about the XSLT working without XMII converting the XML document back to the format it prefers.
Any thoughts or ideas of what I can do about this?
Thanks alot for the help!
KerbyThanks everyone for the response. I think I need to provide a few more details about our implementation to clarify things.
This situation comes up when we are doing a 'CrossTab' or 'Pivot' of data in the database and returning it to the user as a CSV file. The pivoted columns we are creating are the distinct <materialNo>_<ParameterName>_<ParameterUOM> from the original data. The result of the query template is directly returned to the user as a CSV file, and so the columns are never shown in an applet or grid. We are also running into the Oracle 30 character limit for column names, so would prefer to keep the current convention of "14_name_g/L" instead of adding the g_per_L idea. Because we are pivoting on the data present in the original columns, the column name is not known ahead of time.
Is there any way to do change this after retrieving the data from the query template so it can be displayed correctly? Or do I need to look for alternatives?
From the OutputXML of the calling Query Template, an example problem column looks like:
<Column Description="14_Conductivity_g/L" MaxRange="1" MinRange="0" Name="_14_Conductivity_g_L" SQLDataType="12" SourceColumn="14_Conductivity_g/L" />
and then the actual xml rows have the column name as the identifier.
<row>
<_14_Conductivity_g_L>17</_14_Conductivity_g_L>
</row>
What I have tried is to create an xslt which overwrites the column name with column description. That did not work as it still showed the leading '_' and replaced the '/' with '_'. I am not sure if it didn't work because of the inaccurate column name in the row definition or if XMII replaced the column name again with its preferred column definition. I considered trying to change the xslt to also overwrite the columnName in the rows with the correct columnName, but I wasn't sure if that would work either or XMII would overwrite the values anyway?
Thoughts or ideas for workarounds? Or is this pretty much the limitation and need to accept the leading _ and find another separator for g/L?
Thanks alot for the help!
Kerby -
Urgent : Problem in displaying 0fiscper as dynamic data col.
Hi SEM gurus,
I have a problem in displaying 0FISCPER in data columns. Say, in my planning level I have restricted 0FISCPER to 0001.2005 to 012.2005. and I did selected in data column, Dynamic for 0fiscper.
Now when I run my lay out for keyfig. 0Amount the lay out is like this
Customer Amount Amount Amount
Xxxxxx 10 20 30
Its not displaying the month what I want in the lay out should be like this
001.2004 002.2004 003.2004
Customer Amount Amount Amount Amount
Xxxxxx 10 20 30 40 .........
Can any one Please help me out to fix this ???
Thanks a bunch in advance
Rohith.
Message was edited by: rohith gentle
Message was edited by: rohith gentleRohith,
change HEADING column in the 2nd screen of the layout design to "0FISCPER Amount".
I think, current HEADING is named as only "Amount".
This will give layout as
Customer 001.2004Amount 002.2004Amount 003.2004Amount
hope that helps.
Hari Immadi
http://immadi.com
SEM BW Analyst -
Invalid column name: get_column_index
Salam 2all
please help me to solve this problem
i have this error
Invalid column name: get_column_index
when i execute this code
rs = stmt.executeQuery("Select EmpNo,Name,Degree,Occupation,DomainNo,Signature from Employee where EmpNo='"+cno+"'");
if (rs.next())
emp.setText(rs.getString("EmpNo"));
name.setText(rs.getString("Name"));
degree.setText(rs.getString("Degree"));
occ.setText(rs.getString("Occupation"));
int index=SearchIndex(Integer.parseInt(rs.getString("DomainNo"))); dom.setSelectedIndex(index);
domn.setText(rs.getString("Signature"));
By tracing the code using System.out.println("BBBBBBBB");
i reach that the error is in the statment
{ domn.setText(rs.getString("Signature"));
but the spelling for"Signature" is the same, and i write it in the oracle creation table as follow
create table Employee(
EmpNo varchar(40) NOT NULL,
Name varchar(40) NOT NULL,
Degree varchar(4),
Occupation varchar(4),
DomainNo varchar(4),
Signature varchar(40),
primary key(EmpNo ),
foreign key(DomainNo) references Cycle);
Thanks 4 ur help
Salam 2all'Signature' doesn't seem to be a reserved word in Oracle.
First, I would try entering this query from a query tool. That may provide some clues.
Next, I would try changing the column name to 'Signaturexxx' and see if it fixes the problem.
This may be a bug in the driver.
Maybe you are looking for
-
I cannot send Yahoo eMail from iPad or iPhone, but I can receive
I cannot send Yahoo eMail from iPad or iPhone, but I can receive.
-
How to add a new parameter to a forwarded request?
Hi all, I have a RequestDispatcher that forwards my request into a servlet. However, if some processing error happens I would like to include another parameter (an error message) in my request being forwarded. Oh, yes, I don't want it to be via GET,
-
Boot Camp 3.0.4 do not support Windows XP SP2???
Hello! I have my MacBook Pro with Leopard 10.6.8 with Boot Camp 3 on it.Reading a BOOT CAM article I could see that it supports Windows XP SP2.I just installed Windows XP SP2...and when I am trying to use the drivers from MAC DVD it says that BOOT CA
-
Dear SAP Guru's, My Client want to maintain month on month budget for all its department. They require the following: 1. The budget allocated in the first month should be used in that month only(i.e) they cannot carry forward the amount to the next m
-
Problem with Oracle Developer Suite 10g
Hi, I have installed Oracle Developer Suite 10g. When I try to open the rdf file with the report builder, the error message "REP-0756: Warning: Unable to find PL/SQL library 'SHARE_RP'" shown. Does anyone know how to resolve this? Thanks!