Concatenate multiple columns into one string
Hello,
I am using Oracle 11.2, how can I concatenate the value of multiple columns into one string with one SQL:
create table testTb(classId number(5), classRoom varchar2(32));
insert into testTb value(101, 'room101');
insert into testTb value(101, 'room201');
insert into testTb value(101, 'room301');
insert into testTb value(202, 'room444');
insert into testTb value(202, 'room555');
I would like to generate the result as followings:
Class 101 is in room101, room201, room301
Class 202 is in room444, room555
Thanks,
Hi,
Since you're using Oracle 11.2, you can use the aggregate LISTAGG function:
SELECT 'Class ' || classid
|| ' is in '
|| LISTAGG ( classroom
) WITHIN GROUP (ORDER BY classroom)
AS txt
FROM testtb
GROUP BY classid
;The generic name for concatenating all the strings in a group is String Aggregation . This page shows several ways to do it, suitable for different versions of Oracle.
Similar Messages
-
Converting multiple columns into one.
All,
I have a requirement to convert multiple columns into one. Following is the pseudo code of current implementation. It unions the various columns ( col1, col2........) into a new column new_col. But perforamnce is extrmely slow owing to multiple unions. It may be noted that tables and where conditions of all these queries are same.
Can you help me create a more efficient query?
select col1 , col2, col3, col4 from my_tables where some_cols = my_condition;Below is the query used to convert these columns into one.
select col1 new_col from my_tables where some_cols = my_condition
union all
select col2 from my_tables where some_cols = my_condition
union all
select col3 from my_tables where some_cols = my_condition
union all
select col4 from my_tables where some_cols = my_conditionWithout looking at those things you could be barking up the wrong tree by assuming the issue relates to the unioning of queries or other such things.Well, might be.........
Execution time of this query (just the execution time not the retrival) is around 34 seconds with connect-by clause for returning 22,000 records.
Here's the plan
Execution Plan
| Id | Operation | Name | Rows
| Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 326
| 33904 | 135 (2)|
| 1 | SORT ORDER BY | | 326
| 33904 | 135 (2)|
| 2 | MAT_VIEW ACCESS BY INDEX ROWID | MV_COMQ_RM_DEAL | 1
| 62 | 1 (0)|
| 3 | NESTED LOOPS | | 326
| 33904 | 134 (1)|
| 4 | MERGE JOIN CARTESIAN | | 326
| 13692 | 3 (0)|
| 5 | VIEW | | 1
| 13 | 2 (0)|
| 6 | COUNT | |
| | |
| 7 | CONNECT BY WITHOUT FILTERING| |
| | |
| 8 | FAST DUAL | | 1
| | 2 (0)|
| 9 | BUFFER SORT | | 326
| 9454 | 3 (0)|
| 10 | TABLE ACCESS BY INDEX ROWID | SF_SEARCH_IDS_TMP_COMQ | 326
| 9454 | 1 (0)|
| 11 | INDEX RANGE SCAN | IDX1_SF_SEARCH_IDS_TMP_COMQ | 349
| | 1 (0)|
| 12 | INDEX RANGE SCAN | IDX_MV_COMQ_RM_DEAL | 9
| | 1 (0)|
----------------------- Hope, It's readable.......
I would have posted sample data and query but........I cant do that...:( -
Need to concatonate multiple values for same key columns into one string
Hi...I'm attempting to use PL/SQL to read through a table containing more than one column value for a set of keys, and concatonate those values together into one string. For example, in the STUDENT table, for a STUDENT_ID there are multiple MAJORS_ACCOMPLISHED such as History, Biology and Mathematics. Each of the majors is stored in a different row with the same STUDENT_ID due to different faculty DEPARTMENT values.
I want to read through the table and write out a single row for the STUDENT_ID and
concatonate the values for MAJORS_ACCOMPLISHED. The next row should be another STUDENT_ID and the MAJORS ACCOMPLISHED for that student..etc.
I've hit a wall trying to use cursors and WHILE loops to get the results I want. I'm hoping someone may have run across this before and have a suggestion. Tks!!I think you are looking for string aggregation.
The following are the replies posted by me in the forum recently on the same case.
they might help you.
Re: Concatenating multiple rows in a table - Very urgent - pls help
Re: Doubt in a query ( Urgent )
Re: How to remove words which consist of max 2 letters?
Re: output like Name1,Name2,Name3... -
How to concatenate multiple records into one
Hi everybody:
I want to know if exist some way to concat multiple records into one without using cursors. For example, I have a table named "Authors" like this:
Lan|Author
English|Ernest Hemingway
Spanish|Octavio Paz
Spanish|Mario Vargas Llosa
English|Sinclair Lewis
Spanish|Gabriel García Márquez
And I want to get this:
Author
Octavio Paz, Mario Vargas Llosa, Gabriel García Márquez
I have worked with SQL Server and I can do something like this:
CREATE FUNCTION dbo.MyConcat (@lan varchar(10))
RETURNS varchar(5000) AS
BEGIN
declare @retvalue varchar(5000)
set @retvalue=''
select @retvalue = @retvalue + Author +',' from Authors where lan = @lan
return substring(@retvalue,1,len(@retvalue)-1)
END
ie, do not use cursors to concatenate records. However, with ORACLE, I have to do someting like this.
FUNCTION MyConcat(P_Lan IN VARCHAR2) RETURN VARCHAR2 IS
v_ret VARCHAR2(4000);
v_element VARCHAR2(4000);
v_cursor sys_refcursor;
BEGIN
OPEN v_cursor FOR SELECT Author FROM Authors where Lan = P_Lan
LOOP
FETCH v_cursor INTO v_elemento;
EXIT WHEN v_cursor%NOTFOUND;
IF v_ret IS NULL THEN
v_ret := v_element;
ELSE
v_ret := v_ret || ', ' || v_element;
END IF;
END LOOP;
RETURN v_ret;
END;
Exist some other way to do this?
Best Regards
JackTks both for answer... I forgot to mention that I am using Oracle 10g. I read about LISTAGG() but this function is available for Oracle 11g release 2.
I wil read about the other techniques than Hoek mention
Best Regards.
Jack -
Concatenate multiple records into one single record
Hello everyone,
Can anyone guide me how to merge multiple records into one single record
like......... I am getting the data in the file like
aaaaa/bbbbbbb/ccccccccccc/dddddddddddd/eee
ffffff/gggg/hhhhhhhhhhhhhh
/123/4567/55555/99999999/kaoabfa/eee
fffff/kkkkkkkk/llllllllllllllllllllllll
when i use gui_upload I am getting the data into the internal table in the above format.
My main intension is to split the record at / to multiple lines and dowload it into another file.
What i am planning to do is... if the line does not start with / then i want to concatenate the multiple lines into single line and then split it into multiple records. Can anyone guide me how to achieve this.Yes, it should work.
In my example
Loop at itab.
concatenate i_text itab into i_text.
endloop.
You change that loop for the loop of your internal table with the file records
So if you have this three records
'aaaa/bbb/ccc'
'/dddd/efg'
'hijk/lmn'
i_text will look like this at the end
'aaaa/bbb/ccc/dddd/efghijk/lmn'
then in this part of the code
split i_text at '/' into table itab2.
itab2 will have the records looking like this
aaaa
bbb
ccc
dddd
efghijk
lmn' -
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> -
Concatenate multiple tables into one table
Dear all,
I am doing migration between two database structures, that's why I need also to know if we want to concatenate the data in tables A,B and C into one table in the destination schema, what is the strategy to do this knowing that I have a lot of data and I need the fastest solution.
regardsSince the details of your requirements are unclear, will this approach not work ?
SQL> INSERT into target_table
SQL> (SELECT * from tableA UNION
SQL> SELECT * from tableB UNION
SQL> SELECT * from tableC);HTH
Srini -
Concatenate Multiple Columns into Single
Hi All,
I am developing a report and there is a field called FUNDING_SOURCE.
This field is being picked from class_code of PA_PROJECT_CLASSES table as shown below:
(select distinct(class_code)
from pa_project_classes ppc,
pa_projects_all ppa
where class_category = 'FUNDING SOURCE'
and ppc.project_id = :project_id)
But, the requirement is to have all values of Funding Source for a particular project ID concatenated into a single column.
Eg: If I run the above code, the output would be in 3 rows,
Intenal
External
Other
I want the output concatenated and displayed as Internal, External, Other.
Please help me ASAP. Need to finish this soon.
Thanks!SELECT substr(MAX(sys_connect_by_path(a,
'~')),
2) --first character wil be ~ max is used because the query will return 3 rows and u need only one row with all values appended
FROM (SELECT a,
row_number() over(ORDER BY t.b) AS curr, --order in which appending happens
row_number() over(ORDER BY t.b) - 1 AS prev --order in which appending happens
FROM (SELECT 'Internal' a,
1 b
FROM dual
UNION ALL
SELECT 'External' a,
2 b
FROM dual
UNION ALL
SELECT 'Other' a,
3 b
FROM dual) t --creating dummy table
CONNECT BY prev = PRIOR curr
START WITH curr = 1; -
Concatenate Multiple columns to one Row - Oracle 10.1
Hi Friends,
I have the item id in the item table and list of warehouses in another table.
SDM_ITEM_TABLE
ITM_ID ITM_DESC
1 Baby Oil
2 Shampoo
SDM_OUTBOUND_LOG
ITM_ID WHS_ID
1 1
1 2
1 3
1 4
2 1
2 2
SDM_OUTBOUND_DESC
WHS_ID WHS_SNAME
1 NJ
2 WN
3 CA
4 CN
Expected Result
ITM_ID WHS_SNAME
1 NJ WN CA CN
2 NJ WN
I am using the below query to join the above 3 tables , but i am unable to concatenate the warehouse short names as displayed above.
select t.itm_id,(SELECT H.WHS_SNAME FROM SDM_OUTBOUND_DESC H WHERE H.WHS_ID = t.WHS_ID) WHS_SNAME
from SDM_OUTBOUND_LOG t, SDM_ITEM_TABLE i
where t.itm_id = i.itm_id
Please let me know how to proceed further in modifying the query to concatenate the warehouse names.
ThanksCentinul gave you the links to many examples.
You should try them all and find out how they work and let us know what parts are not clear.
Not sure why you are joining all three tables here, it looks like the desired resultset can be selected using
sdm_outbound_log and sdm_outbound_desc only?
One way of concatenating column values, is to use SYS_CONNECT_BY_PATH (but there are many more).
The query below reads from 'inside-out':
SQL> create table sdm_outbound_log as
2 select 1 itm_id, 1 whs_id from dual union
3 select 1, 2 from dual union
4 select 1, 3 from dual union
5 select 1, 4 from dual union
6 select 2, 1 from dual union
7 select 2, 2 from dual;
Table created.
SQL> create table sdm_outbound_desc as
2 select 1 whs_id, 'NJ' whs_sname from dual union
3 select 2, 'WN' from dual union
4 select 3, 'CA' from dual union
5 select 4, 'CN' from dual;
Table created.
SQL> select itm_id
2 , ltrim(replace( sys_connect_by_path(whs_sname, ',')
3 , ',', chr(32)
4 )
5 ) whs_sname
6 from ( select l.itm_id
7 , d.whs_sname
8 , row_number() over (partition by l.itm_id order by l.itm_id) rn
9 from sdm_outbound_log l
10 , sdm_outbound_desc d
11 where d.whs_id = l.whs_id
12 )
13 where connect_by_isleaf=1
14 start with rn=1
15 connect by rn=prior rn+1
16 and itm_id=prior itm_id;
ITM_ID WHS_SNAME
1 NJ WN CA CN
2 NJ WN
2 rows selected.So, in the innermost query we start by using row_number() to obtain a rownumber within each occurence of itm_id,
and then we connect by that rownumber and itm_id in the outermost query.
Since it looks like you want your values delimited by a space, I added a replace and a ltrim. -
Concatenate multiple lines into one
Post Author: [email protected]
CA Forum: General
Hi,I'm trying to pull data out of one table that could have multiple lines (indicated by a line count field for each row). The user wants to see all lines in one field only. I tried the following but am running into issues if there's only one row (one line count). With this, the single row is concatenated with itself. //@groupheader-initilizewhileprintingrecords;stringvar x:=""//@detailwhileprintingrecords;stringvar x:=x+ //@groupfooterwhileprintingrecords;stringvar x Any ideas appreciated. Thanks!Post Author: Charliy
CA Forum: General
Take the initialize formula out of the Group Header.
Place it an the Report Header, and create a second (print suppressed) Group Footer and place it there -
My Example :
Before:
Columns
name
address
jon DFG
has NULL
adil DER
After:
Column
Total
name : jon , address : DFG
name : has
name : adil , address : DERWhy not doing such reports on the client site?
create table #t (name varchar(10),address varchar(20))
insert into #t values ('jon','dfg'),('has',null),('adil','der')
select n,case when right(n,1)=':' then replace(n,'address:','') else n end
from
select concat('name:',name, ' address:',address ) n from #t
) as der
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 -
Multiple ListBox columns into one Textbox
I would like a text box to return several columns from a list box.
Me.TextMulti=Me.ListProduct.Column (*)
*here I would like it to give me columns 55, 95, 95, 97, 98, 99, 100 and 101.
Has anyone any experience with this?
Thank you in advance for any help you can give me.
GeeI would like a text box to return several columns from a list box.
Me.TextMulti=Me.ListProduct.Column (*)
*here I would like it to give me columns 55, 95, 95, 97, 98, 99, 100 and 101.
Has anyone any experience with this?
Thank you in advance for any help you can give me.
You have a list box with 100 columns in it?!! That's a very unusual setup. Why? And why do you need to get multiple columns from it into a single text box? It seems so strange, maybe you're going about something the wrong way.
To answer the question itself, you can concatenate multiple columns from a list box in the controlsource of a text box, but you have to itemize the columns. As for example this ControlSource property for the text box:
=[ListProduct].[Column](55) & "," & [ListProduct].[Column](95) & "," & [ListProduct].[Column](96) & "," & [ListProduct].[Column](97) & "," & [ListProduct].[Column](98)
& "," & [ListProduct].[Column](99) & "," & [ListProduct].[Column](100) & "," & [ListProduct].[Column](101)
That may be too long to fit in the ControlSource property; I'm not sure.
Or you could write a VBA function that concatenates the desired columns, and use that in a function expression for your text box.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
How to concatenate two colums into one single column
I need some ideas to concatenate two different columns into one single column using a set of distinct values.
For Example,
Customer Product Number
xyz A 1
xyz B 2
xyz B 1
AAA C 7
AAA A 1
The result should look like this,
Customer Value
xyz A1 B2 B1
AAA C7 A1
How would I group this into once value ?
Thanks in advance ...Tom's discussion of writing your own aggregate routines
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2196162600402
starts off with a link to the 8i alternatives
"see
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:229614022562
for 8i methods (not aggregates)"
Unforutnately, it's a lot more work in 8i.
Justin -
Storing and retrieving multiple values into one cookie.
Hi Everyone,
I am wondering if anybody knows of any good tutorials involving storing multiple values into one cookie. Any URLs will be greatly apprecated. Thanks heaps.
Regards
DavoThese are normally delimted in HTTP by a semicolon. You can concatenate the string yourself and on the reverse trip use StringTokenizer to get the values back out.
- Saish -
Help needed in returning multiple columns from one field
Hi,
I have been given a task to rewrite the query (see below), so that I get three columns from the one field, based on their contents.
The script returns all the columns and concatenates them into one, but returns them as comma delimmited within the returned column, to generate a report.
These tables are from Siebel.
Our Oracle version is:
select banner from sys.v_$version;
--returns
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for Solaris: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
Here is what I was given;
set arraysize 200
Spool d:\Daily_reports\Data\RegManage\Electricity\eCISPLUS_Product_Switch_Not_Started_Discount.csv
-- this will concatenate all the returned columns into one
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '","' ||
rtrim(ltrim(S_PROD_INT.NAME)) || '"'
The field S_PROD_INT.NAME is the one that I need to split so that it is retured
into three different columns.
1st column needed -
where S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
2nd column needed -
where S_PROD_INT.NAME Like 'Gas TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Gas TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Gas Go for More __ %'
OR S_PROD_INT.NAME Like 'Gas Mates Rates __ %'
3rd column needed from
S_PROD_INT.NAME Like '* ___ Discount for Paying Your Bill by the Due Date')
-- Tables
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST,
SIEBEL.S_PROD_INT S_PROD_INT,
SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND (S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %' OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %' OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
OR S_PROD_INT.NAME Like 'Electricity __ Discount for Paying Your Bill by the Due Date' or S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge ___ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now ___ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More ___ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates ___ %'
OR S_PROD_INT.NAME Like 'Electricity ___ Discount for Paying Your Bill by the Due Date')
UNION
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '"'
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND NOT EXISTS (SELECT /*+ unnest */ 'X'
FROM SIEBEL.S_PROD_INT S_PROD_INT, SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND (S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge __ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now __ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More __ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates __ %'
OR S_PROD_INT.NAME Like 'Electricity __ Discount for Paying Your Bill by the Due Date' or S_PROD_INT.NAME Like 'Electricity TRUenergy Business Edge ___ %'
OR S_PROD_INT.NAME Like 'Electricity TRUenergy Business Now ___ %'
OR S_PROD_INT.NAME Like 'Electricity Go for More ___ %'
OR S_PROD_INT.NAME Like 'Electricity Mates Rates ___ %'
OR S_PROD_INT.NAME Like 'Electricity ___ Discount for Paying Your Bill by the Due Date'));
spool off
This is what one row looks like;
"1-UWLHY","Alpha Vic Kelly Kay","Product Switch-Electricity","Not Started","AMBASS_50REBATE","Go Green PKANY-Powercor","QEGS1","GG","QEGS1","GG","","6407421678","8","1-UWLI6","12-JUN-07","Electricity Mates Rates 7% Discount"
we want
"1-UWLHY","Alpha Vic Kelly Kay","Product Switch-Electricity","Not Started","AMBASS_50REBATE","Go Green PKANY-Powercor","QEGS1","GG","QEGS1","GG","","6407421678","8","1-UWLI6","12-JUN-07",'Electricity Mates Rates 7% Discount","Gas TRUenergy Business Edge 10% Discount","Electricity 3% Discount for Paying Your Bill by the Due Date"
I have tried to:
- create a cursor
- each column as - ie
S_PROD_INT.NAME as "EVD",
S_PROD_INT.NAME as "GVD",
S_PROD_INT.NAME as "PbDDD"
but when I try to use them in where "EVD" Like 'etc...'
error that table does not exist
I have tried also as
where 'EVD' Like 'etc...' -- error
where EVD Like 'etc...' -- error
- create them as %TYPE variable
- more
but keep getting errors
Any ideas and help will be most appreciated as I have tried and researched all I can think and get my hands on with my limited skills.
Thanks.
Regards, SteveUnfortunately my skills are not high enough as I obviously don't know where to put the code exaclty.
I am first just running it on the top part of the script but get the error;
ORA-00900: invalid SQL statement
What I am running is; -- Commented
WITH s_prod_int AS
SELECT 1 row_id, 'Electricity Mates Rates 7% Discount' name FROM s_prod_int --these were 'FROM dual' originally, I changed to s_prod_int (Received same error regardless whether from dual or s_prod_int)
UNION ALL
SELECT 1, 'Gas TRUenergy Business Edge 10% Discount' FROM s_prod_int
UNION ALL
SELECT 1, 'Electricity 3% Discount for Paying Your Bill by the Due Date' FROM s_prod_int
SELECT DISTINCT '"'||
rtrim(ltrim(S_ORG_EXT.OU_NUM)) || '","' ||
rtrim(ltrim(S_ORG_EXT.NAME)) || '","' ||
rtrim(ltrim(S_EVT_ACT.TODO_CD)) || '","' ||
rtrim(ltrim(S_EVT_ACT.EVT_STAT_CD)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_SOURCE_TYPE)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_TXU_PRICELIST_NAME)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PEAKANYTIME_ELEC)) || '","' ||
rtrim(ltrim(S_PRI_LST.X_TXU_CISRATE_PA_CLASS_ELEC)) || '","' ||
rtrim(ltrim(S_ORG_EXT.X_OTH_ACCOUNT_NUMBER)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_NUM)) || '","' ||
rtrim(ltrim(S_ADDR_PER.X_NMI_CHECKSUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.QUOTE_NUM)) || '","' ||
rtrim(ltrim(S_DOC_QUOTE.X_COOLING_OFF_DATE)) || '","' ||
rtrim(ltrim(a.name)) ||'","'|| --I assume I am still able to right and left trim
rtrim(ltrim(b.name)) ||'","'||
rtrim(ltrim(c.name))||'"' name -- not sure what this name is here for (have ran with and without it here
FROM SIEBEL.S_ADDR_PER S_ADDR_PER,
SIEBEL.S_DOC_QUOTE S_DOC_QUOTE,
SIEBEL.S_EVT_ACT S_EVT_ACT,
SIEBEL.S_ORG_EXT S_ORG_EXT,
SIEBEL.S_PRI_LST S_PRI_LST,
s_prod_int a, -- I assume these needed to go in here
s_prod_int b,
s_prod_int c
SIEBEL.S_QUOTE_ITEM S_QUOTE_ITEM
WHERE S_EVT_ACT.TARGET_OU_ID = S_ORG_EXT.ROW_ID
AND S_DOC_QUOTE.ROW_ID = S_QUOTE_ITEM.SD_ID
AND S_ADDR_PER.ROW_ID = S_ORG_EXT.PR_ADDR_ID
AND S_PROD_INT.ROW_ID = S_QUOTE_ITEM.PROD_ID
AND S_ORG_EXT.ROW_ID = S_DOC_QUOTE.TARGET_OU_ID
AND S_DOC_QUOTE.PRI_LST_ID = S_PRI_LST.ROW_ID
AND S_EVT_ACT.TODO_CD = 'Product Switch-Electricity'
AND S_EVT_ACT.EVT_STAT_CD In ('In Progress','Not Started','On Hold')
AND S_DOC_QUOTE.STAT_CD In ('Completed','Verbal Acceptance','Written Acceptance')
AND S_DOC_QUOTE.X_OFFER_TYPE = 'Product Switch'
AND a.NAME LIKE 'Electricity TRUenergy Business Edge%' --Placed all the where part in the original where clause
OR a.NAME LIKE 'Electricity TRUenergy Business Now%'
OR a.NAME LIKE 'Electricity Go for More%'
OR a.NAME LIKE 'Electricity Mates Rates%'
AND a.row_id = b.row_id
AND (
b.NAME LIKE 'Gas TRUenergy Business Edge%'
OR b.NAME LIKE 'Gas TRUenergy Business Now%'
OR b.NAME LIKE 'Gas Go for More%'
OR b.NAME LIKE 'Gas Mates Rates%'
AND b.row_id = c.row_id
AND (
c.NAME LIKE '%Discount for Paying Your Bill by the Due Date'
NAME -- Not sure what this NAME is for - tried with and without - same error
Maybe you are looking for
-
Animated .gif not reloading
Here's my problem: I'm trying to run an animation whenever a certain button is pressed. The file is an animated .gif. It works... but only the first time. I'm trying to figure out how to work more than once. The image is being loaded in a JLabel. Sug
-
Problem in creating a new track
Hi, I am trying to create a new track in NWDi like this 1.created a product,sofware unit and software component and defined the dependencies(required components like BUILDT,JTECHS etc) 2.Went to landscape configurator and clicked on track data and en
-
Trouble scanning 8 1/2 x 14
I just bought and installed Acrobat XI Standard on my PC I have a Brother FMC-430w Print/scan/fax. I was using their Controlcenter 4 software and could scan 81/2 X 14 docs, which is what is reqd for my work. My problem was that I can only load so
-
i purchased songs on itunes that dont show up on my new device. if i go to the itunes store, it says the song is purchased yet still doesnt show up on my itunes...
-
I'm trying to implement an application using a fairly typical MVC architecture. Basically I have a number of classes which represent my data, a variety of interfaces (such as tree interfaces, recordset interfaces) which some or all of my data classes