Merging values of CKFs in two columns into single column
Hi ,
I want to merge values present in two different columns.The values present in rows of one column are not present in rows of other column, I have to merge the values into a single column.so that in the single column i can get all the values.how to do it in BEx.
regards ,
man.
Hi,
Dear murali , the solution you gave has helped me a bit as i am able to get the values for both the formula KF's in the same column,But another problem has arisen.
For both the formula KF's I had to choose 'New Selection' (and not 'New formula')after R-cllick on the structure, as I had to use a Characteristic as restriction for Each of the KF's, and also to use the Characteristic I had to associate it with some KF so that the Characteristic wil be used as a KF in the formula.
Now what is happening is that I am getting the values of that associated KF also in the empty rows.(i.e. the rows where the value of both the KF1 and KF2 is not present)
What has to be done to remove them and keep the empty rows empty and not show the value of the KF taken with the Characteristic for restriction. Also its value is summing up with KF1 and KF2 in the coulmn which is having both KF1 and KF2 together.
Regards
man
Similar Messages
-
Merge multiple columns into single column?
Hi,
I need to execute queries dynamically and return the values. I need to fetch the values of the queries in single column only by concatenating the multiple columns. I cannot use PL/SQL in my scenario.
is there any way to execute a query and the result will be fetched in single column (values of multiple columns needs to be concatenated)?
Thanks,
Raja.hi,
do you mean this??
1* select EMPNO||' '||ENAME||' '||JOB||' '||MGR||' '||HIREDATE||' '||SAL||' '||COMM||' '||DEPTNO||
SQL> /
MULTIPLE_COL
100 JDF DIR 05-SEP-09 200 1000 10
7497 MILLER CLERK 7782 23-JAN-82 25000 195 35
7566 JONES MANAGER 7839 02-APR-81 3175 446.25 20
7654 RAR SALESMAN 7698 28-SEP-81 1450 1587.5 30
7698 BLAKE MANAGER 7839 01-MAY-81 3050 427.5 30
7782 CLARK MANAGER 7839 09-JUN-81 2650 367.5 10
7788 SCOTT ANALYST 7566 09-DEC-82 3200 450 20
7839 KING PRESIDENT 17-NOV-81 5200 8250 10
7844 TURNER SALESMAN 7698 08-SEP-81 1700 225 30
7876 ADAMS CLERK 7788 12-JAN-83 1300 165 20
7900 JAMES CLERK 7698 03-DEC-81 1150 85.5 30 [email protected]
MULTIPLE_COL
7902 FORD ANALYST 7566 03-DEC-81 3200 450 20
8000 KINGBABA PRESIDENT 17-NOV-81 5200 8250 10
8001 TURNER RAV SALESMAN 8000 08-SEP-81 1700 450 30
1001 KITTU DOR 05-SEP-09 1200 100 40
15 rows selected.Or
Mean this??
SQL> ed
Wrote file afiedt.buf
1 With T As
2 ( Select Level col1 From dual Connect By Level<=10
3 )
4 Select Max(SYS_CONNECT_BY_PATH(COL1||',',' ')) Multi_col
5 From
6 ( Select COL1, Lag(COL1) Over (Order By COL1) As Lag
7 From T )
8 Start With Lag Is Null
9 Connect By
10* Prior col1 = LAG
SQL> /
MULTI_COL
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,Edited by: user291283 on Sep 8, 2009 10:10 PM -
Transform Multiple column into single column;
Hi all,
I have a table with multiple columns
Col_1
Col_2
Col1_3
Col_4
Col_5
Col1_6
Col_7
Col_8
Col1_9
Val_1
val_2
Val_3
Val_4
val_5
Val_6
Val_7
val_8
Val_9
Oper1
Oper2
Oper9
Currently the table look like this
ID Name | f_actve | Col_1| Col_2|….Col1_9| Val_1| val_2| …Val_9| Oper1…..| Oper9
Now I need to insert the data into new table The structure of the new table look like this
Table : T1 (header)
ID | Name | F_active
Table : T2 (detail )
Dtl ID | Columnname | Oper
Now all the column_name Col_1through Col_9 should be inserted into column_name column.
Same thing with the Opers
Table T3(detail )
DTL_ID | Column_Values
Now all the Column_Values Col_1through Col_9 should be inserted into column_name column
Please help
We have 10G /11g.
Thanks
RebeccaWhat you are trying to do is called unpivot in 11g.
See this example.
SQL> WITH T
2 AS (SELECT 1 dtl_id,
3 1 col1,
4 2 col2,
5 3 col3,
6 4 col4
7 FROM DUAL)
8 SELECT * FROM T;
DTL_ID COL1 COL2 COL3 COL4
1 1 2 3 4
SQL> WITH T
2 AS (SELECT 1 dtl_id,
3 1 col1,
4 2 col2,
5 3 col3,
6 4 col4
7 FROM DUAL)
8 SELECT dtl_id, "COL_VALUES"
9 FROM T UNPIVOT (col_values FOR abc IN (col1, col2, col3, col4));
DTL_ID COL_VALUES
1 1
1 2
1 3
1 4
SQL> -
How can I separate one column into multiple column?
How can I separate one column into multiple column?
This is what I have:
BUYER_ID ATTRIBUTE_NAME ATTRIBUTE_VALUE
0001 PHONE_NUMBER 555-555-0001
0001 EMAIL [email protected]
0001 CURRENCY USD
0002 PHONE_NUMBER 555-555-0002
0002 EMAIL [email protected]
0002 CURRENCY USD
0003 PHONE_NUMBER 555-555-0003
0003 EMAIL [email protected]
0003 CURRENCY CAD
This is what I would like to have:
BUYER_ID PHONE_NUMBER EMAIL CURRENCY
0001 555-555-0001 [email protected] USD
0002 555-555-0002 [email protected] USD
0003 555-555-0003 [email protected] CAD
Any help would be greatly appreciated.This is another solution. Suppose your actual table's name is test(which has the redundant data). create a table like this:
CREATE TABLE test2 (BUYER_ID number(10),PHONE_NUMBER varchar2(50),EMAIL varchar2(50),CURRENCY varchar2(50));
then you will type this procedure:
declare
phone_number_v varchar2(50);
EMAIL_v varchar2(50);
CURRENCY_v varchar2(50);
cursor my_test is select * from test;
begin
for my_test_curs in my_test loop
select ATTRIBUTE_VALUE INTO phone_number_v from test
where person_id=my_test_curs.person_id
and attribute_name ='PHONE_NUMBER';
select ATTRIBUTE_VALUE INTO EMAIL_v from test
where person_id=my_test_curs.person_id
and attribute_name ='EMAIL';
select ATTRIBUTE_VALUE INTO CURRENCY_v from test
where person_id=my_test_curs.person_id
and attribute_name ='CURRENCY';
INSERT INTO test2
VALUES (my_test_curs.person_id,phone_number_v,EMAIL_v,CURRENCY_v);
END LOOP;
END;
Then you will create your final table like this:
create table final_table as select * from test2 where 1=2;
After that write this code:
INSERT ALL
into final_table
SELECT DISTINCT(BUYER_ID),PHONE_NUMBER,EMAIL,CURRENCY
FROM TEST2;
If you have a huge amount of data in your original table this solution may take a long time to do what you need. -
How to put 2nd column into 1st column in excel
Hello,
I have a question how to put 2nd column into 1st column in excel. Thank you.
Solved!
Go to Solution.Why the 1 iteration for loops?
Why the two Index Arrays? It is just trying to fix the problem created by the For Loops on the original 1-D arrays.
Both of those things are creating 2-D arrays that are complicating things and can be eliminated.
You can take your 2 1-D arrays, use Build Array and right click to set "Concatenate Inputs".
If you do have a 2-D array, you can use Reshape Array to make it a 1 column by N row 2-D array. -
How to convert single column into single row
I need to convert single column into single row having n no.of.values in a column. without using case or decode. I need a query to display as below.
emp_id
100
101
102
102
103
200
I need output like 100,101,102,103,104.........200.I assume you want to convert 200 rows with one column into one row with 200 columns. If so, this is called pivot. If you know number of rows (max possible number of rows) and you are on 11G you can use PIVOT operator (on lower versions GROUP BY + CASE). Otherwise, if row number isn't known, you can use dynamic SQL or assemble select on clent side. Below is example emp_id = 1,2,..5 (to give you idea) and you are on 11G:
with emp as (
select level emp_id
from dual
connect by level <= 5
select *
from emp
pivot(
max(emp_id) for emp_id in (1 emp_id1,2 emp_id2,3 emp_id3,4 emp_id4,5 emp_id5)
EMP_ID1 EMP_ID2 EMP_ID3 EMP_ID4 EMP_ID5
1 2 3 4 5
SQL>
SY. -
Select multiple column into one column
Hi..!!!
Is it possible to select 4 columns in to 1 columns?
I've major1, major 2, major 3, major 4 and i want to retrieve all the columns into one column called "Majors".
Is it possible? if yes then how?
Help me out.
Thanks,
HimadriIf you had given a proper example this thread would have been over in two posts. What you are looking for is often described as an UNPIVOT.
I tend to use a collection type for this, e.g.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CREATE OR REPLACE TYPE varchar2_table AS TABLE OF VARCHAR2 (4000);
2 /
Type created.
SQL> SELECT empno, column_value
2 FROM emp, TABLE (varchar2_table (ename, job));
EMPNO COLUMN_VALUE
7369 SMITH
7369 CLERK
7499 ALLEN
7499 SALESMAN
7521 WARD
7521 SALESMAN
7566 JONES
7566 MANAGER
7654 MARTIN
7654 SALESMAN
7698 BLAKE
(snipped)
28 rows selected.
SQL> -
Splitting one column into different columns.
Hello Experts,
How do i split datetime column into different columns while doing a Select statement.
Ex:
The column "REC_CRT_TS" has data like "2014-05-08 08:23:09.0000000".The datatype of this column is "DateTime". And i want it in SELECT statement like;
SELECT
YEAR(DATETIME) YEAR,
MONTH(DATETIME) MONTH,
DATENAME(DATETIME) MONTHNAME,
DATEPART(DATETIME) WEEKNUM,
DAY(DATETIME) DATE,
DATEPART(DATETIME) HOUR
FROM TABLE_NAME;
The output should look like this;
--YEAR| MONTH | MONTHNAME| WEEKNUM | DATE | HOUR
--2014| 5 | May | 25 | 08 |08
Any suggestions please.
Thanks!
RahmanI made a very quick research and I see in this blog post
http://www.jamesserra.com/archive/2011/08/microsoft-sql-server-parallel-data-warehouse-pdw-explained/
that It also uses its own query engine and not all features of SQL
Server are supported. So, you might not be able to use all your DBA tricks. And you wouldn’t want to build a solution against SQL Server and then just hope to upsize it to Parallel Data Warehouse Edition.
So, it is quite possible that this function doesn't exist in PDW version of SQL
Server. In this case you may want to implement case based month name or do it in the client application.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Splitting one column into 4 columns
Hi,
I want to split one column into 4 columns as shown below.
parameters
PanelPanel=MP01110201&YearYear=2013&Source=1&UserID=aad2779
PanelPanel=MP12100173&YearYear=2013&Source=1&UserID=aac6440
it should be display as
panel yearyear source userid
MP01110201 2013 1 aad2779
MP12100173 2013 1 aac6440
there will be thousands of rows in the column. Can anybody help how to split it as shown.The length may very from row to row
Thanks for your help.........
BALUSUSRIHARSHAIt is working...thank u very much... I found one more issue here
PanelPanel=MP01110201&YearYear=2013&Source=1&UserID=aad2779
PanelPanel=MP11100070&Source=1&PNR=2&YearYear=2014&UserID=ddc1535
PanelPanel=MP11101276&Source=1&YearYear=2014&PNR=2&UserID=ddc1565
I found 3 kinds of formats in the same column... I didn't observe the data carefully while posting the
question..sorry about that. In this case if we need to show as
panel yearyear source
userid
MP01110201 2013 1 aad2779
MP11100070 2014 1 ddc1535
MP11101276 2014
1 ddc1565
is it possible to filter like this? Should we use any case statement in query while we have diff formats
like this?
BALUSUSRIHARSHA -
Convert different rows into single column
DB : 11.1.0.7
OS : Solaris Sparc 5.10
I have one query which is joining few tables and giving me output like below.
personnum orgnm
======= =======
6 Keyholder
9 Sales
3 Mgmt
I would like to convert that into single column like below.
col1
========
6,Keyholder,9,Sales,3,Mgmt
I have tried with pivot and decode, but not getting resule which I am exepcting. Any suggesstions ?yashwanth437 wrote:
listagg() function could work.LISTAGG is not available in 11.1. It was introduced in 11.2.
Anyway, XML solution:
with sample_table as (
select 6 personnum,'Keyholder' orgnm from dual union all
select 9,'Sales' from dual union all
select 3,'Mgmt' from dual
select rtrim(xmlagg(xmlelement(e,personnum || ',' || orgnm,',').extract('//text()')),',') col1
from sample_table
COL1
6,Keyholder,9,Sales,3,Mgmt
SQL> SY. -
How to Splilit The String Into Single Column using Comma As Delimiter ?
How to Splilit The String Into Single Column using Comma As Delimiter ?
using Functionrefer my thread ,code is also available see if that helps you
error while executing the sp ORA-21779: duration not active -
Merge two resultsets into one column
Hi Guys,
I have two SQL statements. The first returns 12 columns and the second returns 2 columns but both return the same number of rows. I can't seem to merge both the queries into a common query as the WHERE clauses in both are different. I have to dump the output into a table i created. The table has 14 columns. One column in both queries act as primary key and they help form the relationship between the resultsets. The column name is SUBSCR_CODE. Below you will find my SQL queries and the CREATE TABLE statement. Please could someone tell me how to achieve this.
SELECT o.subscr_code,
SUM(NVL(m.remain_capital,0)),
SUM(NVL(m.remain_interest,0)),
SUM(NVL(m.remain_debtor_fee,0)),
SUM(NVL(s.remain_debtor_fee,0)),
SUM(NVL(m.remain_costs_to_client,0)),
SUM(NVL(m.remain_debtor_outlay,0)),
SUM(NVL(s.remain_debtor_outlay,0)),
SUM(NVL(m.debtor_exp_outlay,0)),
SUM(NVL(s.debtor_exp_outlay,0)),
SUM(NVL(m.vatbase_debtor_fee,0)),
SUM(NVL(s.vatbase_debtor_fee,0)),
NULL
FROM kkrpt1 o,
maincase m,
subcase s
WHERE o.maincase_id = m.maincase_id
AND m.maincase_id = s.mc_maincase_id
AND s.claim_type IN (6,7,8,9,10,11,13)
AND s.subcase_no = 0
AND m.closing_date IS NULL
AND s.closing_date IS NULL
GROUP BY subscr_code;
SELECT o.subscr_code,
SUM(NVL(a.remain_interest,0))
FROM kkrpt1 o,
amount a,
maincase m,
subcase s
WHERE o.maincase_id = a.mc_maincase_id
AND o.maincase_id = m.maincase_id
AND m.maincase_id = s.mc_maincase_id
AND s.claim_type IN (6,7,8,9,
10,11,13)
AND s.subcase_no = 0
AND m.closing_date IS NULL
AND s.closing_date IS NULL
AND a.amount_type = 41
GROUP BY subscr_code;
CREATE TABLE kk_ajot_14 (
subscr_code VARCHAR2(5),
remain_capital_sum NUMBER,
remain_inerest_sum_1 NUMBER,
remain_debtor_fee_sum_1 NUMBER,
remain_debtor_fee_sum_2 NUMBER,
remain_costs_to_client NUMBER,
remain_debtor_outlay_1 NUMBER,
remain_debtor_outlay_2 NUMBER,
remain_debtor_exp_outlay_1 NUMBER,
remain_debtor_exp_outlay_2 NUMBER,
vatbase_debtor_fee_1 NUMBER,
vatbase_debtor_fee_2 NUMBER,
remain_inerest_sum_2 NUMBER);No need to create table
with
sql_1 as
(<first sql here>
sql_2
(<second sql here>
select a.*,b.*
from sql_1 a,sql_2 b
where a.subscr_code = b.subscr_codeRegards
Etbin -
Concatenate multiple row values into single column value
Hello,
Can anyone please refresh my memory on how to concatenate multiple row values into a single column value.
In the following query, I will get multiple denial reasons per application and I would rather return all denial reasons on one line.
SELECT a.application_id, a.membership_number,
r.reason_text AS denial_reason,
a.appl_receipt_date AS application_receipt_date,
a.plan_request_1 AS application_plan_code,
a.adjudication_date AS application_denial_date
FROM application a, PLAN p, application_reason ar, reason r
WHERE a.plan_request_1 = p.plan_cd
AND a.application_id = ar.application_id
AND ar.reason_id = r.reason_id
AND a.adjudication_cd = 'D'
AND a.appl_receipt_date BETWEEN '01-jan-2006' AND '31-dec-2006'
AND p.plan_type_id = 12 and a.application_id = :appId
ORDER BY application_id
Any help is greatly appreciated.
Thanks,
-Christinefound the following
SELECT deptno,
LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT deptno,
ename,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
FROM emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 ADAMS,FORD,JONES,SCOTT,SMITH
30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
3 rows selected.at http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
Concat rows values into single column
Hi All,
How can I concat values of a multiple rows into a single column by separating them by comma.
Eg:
SELECT empno FROM emp;
empno
1
2
3
4
I want output should be:
Empnos
1,2,3,4
Thanks & Regards,
DanishMichaelS wrote:
Or
SQL> select rtrim(xmlagg(xmlelement(e, empno || ',')).extract('//text()').extract('//text()') ,',') empnos from emp
EMPNOS
7369,7499,7521,7566,7654,7698,7782,7788,7839,7844,7876,7900,7902,7934
Hi Michael,
is it an error or is it correct to put extract 2 times? This is giving to me the same result:
select rtrim(xmlagg(xmlelement(e, empno || ',')).extract('//text()'),',') empnos from emp;
EMPNOS
7369,7499,7521,7566,7654,7698,7782,7788,7839,7844,7876,7900,7902,7934 Regards.
Al -
Retrieve of data from two columns into one column
For eg: i have a data in a table with columns A & B of same size
A B
1 2
2
3 1
4 2
5 3
6 5
7 1
8 4
9
10 8
Through a select i want the output of my data in one single
columns, Well I can do this by using union.
But my output should be like
if I select by condition where A=2
my output should be
2
1
3
7
4
because all these numbers are linked with 2 how do i do this
because it is like searching the number 2 in two columns and wherever this number 2 is linked i should get all the data relevant to it.
Hope u got my point what i exactly want
Can anyone help me it is quite urgent.
Regards
Vamsi Mohani do not a concatenated data
i have a data in a table with columns A & B of same size
A B
1 2
2
3 1
4 2
5 3
6 5
7 1
8 4
9
10 8
if my where condition is 'where A=2'
my output should be
1
2
3
4
5
6
8
10
i want my query to search as loop so that it keeps on searching
for related data as in my case it is
2 is linked to 1
1 is linked to 3
3 is linked to 4
my query should keep on seaching for linked numbers till
it does not find any mathing linked numbers
and the resulted output should come in one single column
Maybe you are looking for
-
I created some brochures at vista-print and i want to e-mail previous prospects our new pricing
-
BAPI_ACC_DOCUMENT_CHECK for Vendor Items
Hi friends, I am using the BAPI BAPI_ACC_DOCUMENT_CHECK to check the data to be posted for Vendor lines items. It is giving the error: 'For document type RE, an entry is required in field Reference' I have written the code like this: Loop at t_fi
-
dictation worked now it won't
-
Infocube load failure post Support Pack Implementation
Hi, We upgraded our BI 7.0 system to Support pack 21 and since then the data load to InfoCube has been failing. The Short Dump details is as mentioned: Error analysis An exception occurred which is explained in detail below. The exception, wh
-
Recording in a small room need help
Hi Everyone. I am new to the art of audio but have worked with video for a few years. I recently filmed an interview. It was in a small room and the Audio has a touch of echo on it. Basically it just sounds like it was recorded in a small room which