How to display the multiple rows in a single column ?
Hi,
I have the Query like this :
SELECT MS.SUBJECT, MS.MESSAGEDESC, MS.MSGDATE, MAT.ATTACHMENT
FROM MESSAGES MS, MSESAGEATTACHEMTASSO MAA, (select pga.programid,
act.accountname,
row_number() over(partition by pga.programid order by act.accountname) rn
from accounttypes act, programpursesasso pga
where act.accounttypeid = pga.accounttypeid ) MSGATTACHMENTS
WHERE MS.MESSAGEID = MAA.MESSAGEID
AND MAA.MSGATTACHMENTID = MAT.MSGATTACHMENTID
AND MS.MESSAGEID = 1;
If i have multiple messageAttachments for single message ., i want to display them in a single row.,
like :
subject messagedesc msgdate attachment1 attachment2 .....attachmentn
test test 10/10/2007 test test test
can any one help me out ., how can i do this using simple sql query ?
Hi,
Thanks for the Reply .,
I have the 2 table like :
DESC MESSAGES;
Name Type Nullable Default Comments
MESSAGEID NUMBER(16)
EMAILFROM VARCHAR2(50) Y
EMAILTO VARCHAR2(50) Y
SUBJECT VARCHAR2(500) Y
MESSAGEDESC VARCHAR2(2000) Y
MSGDATE DATE Y
MSGSTATUS NUMBER(1) Y
MSGDELETESTATUS NUMBER(1) Y
SQL> DESC MESSAGES;
Name Type Nullable Default Comments
MESSAGEID NUMBER(16)
EMAILFROM VARCHAR2(50) Y
EMAILTO VARCHAR2(50) Y
SUBJECT VARCHAR2(500) Y
MESSAGEDESC VARCHAR2(2000) Y
MSGDATE DATE Y
MSGSTATUS NUMBER(1) Y
MSGDELETESTATUS NUMBER(1) Y
SQL> DESC MSGATTACHMENTS;
Name Type Nullable Default Comments
MSGATTACHMENTID NUMBER(16)
ATTACHMENT CLOB
ATTACHMENTDATE DATE Y
SQL> DESC MSESAGEATTACHEMTASSO;
Name Type Nullable Default Comments
MSGATTCHID NUMBER(16)
MESSAGEID NUMBER(16) Y
MSGATTACHMENTID NUMBER(16) Y
What I need Is :
If One Msg is having multiple attachement , then i want to display all the attachment in a single row along with MsgSubject, MsgDate, MsgDesc like
I want to dipaly the MsgSubject, MsgDesc, MsgDate, Attachment1
MsgSubject MsgDate Msgdesc Attachment1 Attachment2 Attachment3 ...etc
Similar Messages
-
How to retrieve the multiple rows data on PDF form in a web service method using WSDL DataConnection
How to retrieve the multiple rows data on PDF form in a web service method using WSDL DataConnection.
I have a multiple rows on PDF form. All rows have 4 textfields. I want to submit the multiple rows data to a method defiened in webservice.
Unable to retrieve the data in multiple rows within webservice method.Hi Paul,
I'm now able to save the retrieved xml in a hidden text field and create dynamic table, and I'm able to fill this table from the XML, but the problem is that I could not find the correct way to loop on the xml, what I'm trying to say, the table will have number of rows with the data of the first row only, so can you tell me the right way to loop on the xml!
this is my code
TextField1.rawValue=xmlData.document.rawValue;
xfa.datasets.data.loadXML(TextField1.rawValue, true, false);
for(var i=0; i<count; i++)
xfa.form.resolveNode("form1.P1.Table1.Row1["+i+"].Num").rawValue = xfa.datasets.data.record.num.value;
xfa.form.resolveNode("form1.P1.Table1.Row1["+i+"].Name").rawValue = xfa.datasets.data.record.name.value;
Table1.Row1.instanceManager.addInstance(true);
Thanks
Hussam -
How do I insert multiple rows from a single form ...
How do I insert multiple rows from a single form?
This form is organised by a table. (just as in an excel format)
I have 20 items on a form each row item has five field
+++++++++++ FORM AREA+++++++++++++++++++++++++++++++++++++++++++++++++++++
+Product| qty In | Qty Out | Balance | Date +
+------------------------------------------------------------------------+
+Item1 | textbox1 | textbox2 | textbox3 | date +
+ |value = $qty_in1|value= &qty_out1|value=$balance1|value=$date1 +
+------------------------------------------------------------------------+
+Item 2 | textbox1 | textbox2 | textbox4 | date +
+ |value = $qty_in2|value= $qty_out1|value=$balance2|value=$date2 +
+------------------------------------------------------------------------+
+ Item3 | textbox1 | textbox2 | textbox3 | date +
+------------------------------------------------------------------------+
+ contd | | | +
+------------------------------------------------------------------------+
+ item20| | | | +
+------------------------------------------------------------------------+
+ + + SUBMIT + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Database Structure
+++++++++++++++++
+ Stock_tabe +
+---------------+
+ refid +
+---------------+
+ item +
+---------------+
+ Qty In +
+---------------+
+ Qty Out +
+---------------+
+ Balance +
+---------------+
+ Date +
+++++++++++++++++
Let's say for example user have to the use the form to enter all 10 items or few like 5 on their stock form into 4 different textbox field each lines of your form, however these items go into a "Stock_table" under Single insert transaction query when submit button is pressed.
Please anyone help me out, on how to get this concept started.Hello,
I have a way to do this, but it would take some hand coding on your part. If you feel comfortable hand writing php code and doing manual database calls, specificaly database INSERT calls you should be fine.
Create a custom form using the ADDT Custom Form Wizard that has all the rows and fields you need. This may take a bit if you are adding the ability for up to 20 rows, as per your diagram of the form area. The nice thing about using ADDT to create the form is that you can setup the form validation at the same time. Leave the last step in the Custom Form Wizard blank. You can add a custom database call here, but I would leave it blank.
Next, under ADDT's Forms Server Behaviors, select Custom Trigger. At the Basic tab, you enter your custom php code that will be executed. Here you are going to want to put your code that will check if a value has been entered in the form and then do a database INSERT operation on the Stock_table with that row. The advanced tab lets you set the order of operations and the name of the Custom Trigger. By default, it is set to AFTER. This means that the Custom Trigger will get executed AFTER the form data is processed by the Custom Form Transaction.
I usually just enter TEST into the "Basic" tab of the Custom Trigger. Then set my order of operations in the "Advanced" tab and close the Custom Trigger. Then I go to the code view for that page in Dreamweaver and find the Custom Trigger function and edit the code manually. It's much easier this way because the Custom Trigger wizard does not show you formatting on the code, and you don't have to keep opening the Wizard to edit and test your code.
Your going to have to have the Custom Trigger fuction do a test on the submitted form data. If data is present, then INSERT into database. Here's a basic example of what you need to do:
In your code view, the Custom Trigger will look something like this:
function Trigger_Custom(&$tNG) {
if($tNG->getColumnValue("Item_1")) {
$item1 = $tNG->getColumnValue("Item_1");
$textbox1_1 = $tNG->getColumnValue("Textbox_1");
$textbox1_2 = $tNG->getColumnValue("Textbox_2");
$textbox1_3 = $tNG->getColumnValue("Textbox_3");
$date1 = $tNG->getColumnValue("Textbox_3");
$queryAdd = "INSERT INTO Stock_table
(item, Qty_In, Qty_Out, Balance, Date) VALUES($item1, $textbox1_1, $textbox1_2, $textbox1_3, $date1)"
$result = mysql_query($queryAdd) or die(mysql_error());
This code checks to see if the form input field named Item_1 is set. If so, then get the rest of the values for the first item and insert them into the database. You would need to do this for each row in your form. So the if you let the customer add 20 rows, you would need to check 20 times to see if the data is there or write the code so that it stops once it encounters an empty Item field. To exit a Custom Trigger, you can return NULL; and it will jump out of the function. You can also throw custom error message out of triggers, but this post is already way to long to get into that.
$tNG->getColumnValue("Item_1") is used to retrieve the value that was set by the form input field named Item_1. This field is named by the Custom Form Wizard when you create your form. You can see what all the input filed names are by looking in the code view for something like:
// Add columns
$customTransaction->addColumn("Item_1", "STRING_TYPE", "POST", "Item_1");
There will be one for each field you created with the Custom Form Wizard.
Unfortunately, I don't have an easy way to do what you need. Maybe there is a way, but since none of the experts have responded, I thought I would point you in a direction. You should read all you can about Custom Triggers in the ADDT documentation/help pdf to give you more detailed information about how Custom Triggers work.
Hope this helps.
Shane -
How To Concatenate Column Values from Multiple Rows into a Single Column?
How do I create a SQL query that will concatenate column values from multiple rows into a single column?
Last First Code
Lesand Danny 1
Lesand Danny 2
Lesand Danny 3
Benedi Eric 7
Benedi Eric 14
Result should look like:
Last First Codes
Lesand Danny 1,2,3
Benedi Eric 7,14
Thanks,
David JohnsonStarting with Oracle 9i
select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
from
(select last, first, code, row_number() over(partition by last, first order by code) rn
from a)
connect by last = prior last and first = prior first and prior rn = rn -1
start with rn = 1
group by last, first
LAST FIRST CODES
Lesand Danny 1,2,3
Benedi Eric 7,14Regards
Dmytro -
I wanted to display the multiple rows in one row but column should be diff
Hi
Could any body help me regarding this query how to write to get the multiple rows in one row.
eg.
i have one table tab1(eno number,ename varchar2,uid1 varchar2,uid2 varchar2,uid3 varchar4)
but when i am runing the query I am getting multiple record against one eno number because of uid1,uid2,uid3
suppose value of table is
eno ename uid1 uid2 uid3
1 a u1
1 a u2
1 a u3
when i am quering it is coming same as above but I want in one row
eno ename uid1 uid2 uid3
1 a u1 u2 u3
can any onle help me how to write the query for this requirement.
thanks
saifwhich is hard coded in my code? Here another approach, but fail for c as there is no information for the value of a column: does 1 in u1 means col 1, etc.
/* Formatted on 2012/05/29 16:29 (Formatter Plus v4.8.8) */
WITH t AS
(SELECT 1 col1, 'a' col2, 'u1' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'a' col2, 'u2' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'a' col2, 'u3' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'b' col2, 'u1' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'b' col2, 'u3' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'b' col2, 'u2' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'c' col2, 'u1' col3
FROM DUAL
UNION ALL
SELECT 1 col1, 'c' col2, 'u3' col3
FROM DUAL)
SELECT xx.col1, xx.col2, MAX (DECODE (xx.rn, 1, col3)) AS uid1, MAX (DECODE (xx.rn, 2, col3)) AS uid2,
MAX (DECODE (xx.rn, 3, col3)) AS uid3
FROM (SELECT t.col1, t.col2, t.col3, ROW_NUMBER () OVER (PARTITION BY col1, col2 ORDER BY col3) rn
FROM t) xx
GROUP BY col1, col2;output:
COL1 COL2 UID1 UID2 UID3
1 a u1 u2 u3
1 b u1 u2 u3
1 c u1 u3
Edited by: ʃʃp on May 29, 2012 2:30 AM -
How to display the multiple lines text in a single - String, StringBuffer
Hi,
I have a textarea field named Decription which contains more than one line seperated by new line.I need to display those five lines in a single text without breaking. Is it possible? I am getting ArrayIndexOutOfBoundsException while i reached to the end of the line. Plz help me how to align the below code so that i can display the lines as a single line in my excel sheet.
if(op.getDescription()!=null)
String[] oppDescs = op.getDescription().split("\n");
StringBuffer sb = new StringBuffer();
for(int i1=0; i<=oppDescs.length-1;++i1)
*writeFile(sb.append(oppDescs[i1]), valueWriter);*
} else {
writeFile(op.getDescription(), valueWriter);
private void writeFile(java.lang.Object value,PrintWriter valueWriter)
if(value!=null)
valueWriter.print(value);
}Thanks and Regardsprevious was java1.5
heres a 1.1 - 1.4 version
String[] oppDescs = op.getDescription().split("\n");
StringBuffer sb = new StringBuffer();
for(int i = 0; i < oppDescs.length : i++){
sb.append(oppDescs);
sb.append( '\t' );
writeFile(sb.toString(), valueWriter );Edited by: simon_orange on 31-Oct-2008 13:02 -
How to display the last row in a table
I have a table that is constantly updating, and I always want to see the last row. How can I get my table to auto scroll?
Hi žabić,
there is a property called "top left visible row". You can use it to scroll your table.
edit:
Maybe this is not the exact name, but you can see an example here
Mike
Message Edited by MikeS81 on 05-27-2010 03:57 PM -
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 -
How to display differnt time fields in a single column?
Hello Sir,
I am trying to display the records which show the table with 3 columns filename,Date,status using jsp.
I am fetching the records from the DB and displaying them using jsp ,connection,resultset, <table> etc.
what i wanted to display is just 3 colms(filename,date,status)
here based on the status it should display the date,becaz table contains different date fieldcolumn for each status value.
here is my code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Content Dash Board</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();%>
<%
int current = 1;
if(request.getParameter("current") != null) {
current = Integer.parseInt(request.getParameter("current"));
int skip = 5;
String action = "";
if(request.getParameter("action") != null) {
action = request.getParameter("action");
if ( action.equals("next") ) {
current += skip;
if ( action.equals("prev") ) {
current -= skip;
%>
<p> </p>
<p> </p>
<p> </p>
<HTML>
<HEAD>
<TITLE>Content Dash Board </TITLE>
</HEAD>
<FORM NAME="form1" ACTION="dashboard.jsp" METHOD="POST">
<p> </p>
<%
Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;databaseName=trax;selectMethod=cursor","sa","iso*help");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet resultset =
stmt.executeQuery("select * from ContentBatches");
resultset.last();
int rows = resultset.getRow();
if ( current >= rows ) current = rows-skip;
if ( current < 0 ) current = 1;
resultset.absolute(current);
%>
<TABLE BORDER="1">
<TR>
<TH bgcolor=#C6C3C6>File/BatchName</TH>
<TH bgcolor=#C6C3C6>Date</TH>
<TH bgcolor=#C6C3C6>Status</TH>
</TR>
<%
int i=0;
boolean next = false;
java.text.SimpleDateFormat fmt= new java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a ");
DecimalFormat df = new DecimalFormat( "###,###,###,000,000" );
String filename=null;
String status=null;
do{
i++;
filename=resultset.getString(2);
status=resultset.getString(8);
%>
<TR>
<TD> <%= filename %> </TD>
<%
if(status.equals("Received"))
out.println("status is:"+status+"time stamp is :"+fmt.format(resultset.getTimestamp(7)));
%>
<TD><%= fmt.format(resultset.getTimestamp(7)) %></TD>
<%
else if(status.equals("Validated"))
%>
<TD><%= fmt.format(resultset.getTimestamp(5)) %> </TD>
<%
else if(status.equals("Published"))
%>
<TD><%= fmt.format(resultset.getTimestamp(4)) %> </TD>
<%
else if(status.equals("Uploaded"))
%>
<TD><%= fmt.format(resultset.getTimestamp(6)) %> </TD>
<%
else
%>
<TD>No data for this option</TD>
<%
%>
<TD> <%= status%></TD>
<td><a href="edit.jsp?BatchId=<%=resultset.getString(2)%>&DateTimeStampPublished=<%=resultset.getString(4)%>&Status=<%=resultset.getString(8)%>">Edit</a></td>
</TR>
<%
while((next=resultset.next()) && i<skip);
%>
</TABLE>
<p>
<BR>
<INPUT TYPE="HIDDEN" NAME="current" VALUE="<%=current%>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="next">
<%
if(next) {
%>
<INPUT TYPE="BUTTON" VALUE="Next Record" ONCLICK="moveNext()">
<%
if(current > 0) {
%>
<INPUT TYPE="BUTTON" VALUE="Previous Record" ONCLICK="movePrevious()">
<%
%>
</p>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
function moveNext()
form1.action.value = 'next';
form1.submit()
function movePrevious()
form1.action.value = 'prev';
form1.submit()
</SCRIPT>
</body>
</html>i am very new to jsp sir, i haven't worked on servlet
, how do i implement the same code in servlet
could you provide me the steps , putting jar files
and all ?I'm not here to tutor you. You can read this:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
Servlets aren't difficult, and actually JSPs are nothing but servlets with a different syntax either. -
Create a view to shows data from multiple rows in a single column
Hi all - this is probably posted in the wrong forum but I couldn't find which was the correct one.
I am almost a complete novice at sql but I have a need to create a view which can be developed at 10g (which runs efficiently as the volumes are likely to be high) which will do the following.
Original table with columns Parent_code, Child_code
Parent_Code Child_Code
1000 2000
1000 3000
1000 4000
2000 3000
2000 5000
(note Parents can have multiple children and a child can have multiple parents!)
What I need to end up with in my view is the following
Child_Code Parent_List
2000 '1000 (3)'
3000 '1000 (3), 2000 (2)'
4000 '1000 (3)'
5000 '2000 (2)'
Note the number in parantheses is the number of children that the parent has - ie in the original table parent 1000 has 3 rows (one for each child)
This view is then to be used as a look up (on child code) for a business objects report.
Is there anyone who could PLEASE, PLEASE help me fairly quickly on this as I have very little time to find a solution?Hi,
You can test these ones :
select child_code
, ltrim(sys_connect_by_path(parent_info,', '), ', ') as parent_list
from (
select child_code
, to_char(parent_code) ||
' (' ||
count(*) over(partition by parent_code) ||
')' as parent_info
, row_number() over(partition by child_code order by parent_code) rn
from your_table
where connect_by_isleaf = 1
connect by prior rn = rn-1
and prior child_code = child_code
start with rn = 1
select child_code,
rtrim(
extract(
xmlagg(xmlelement("e",parent_info||', ') order by parent_info)
, '//text()'
) as parent_list
from (
select child_code,
to_char(parent_code) ||
' (' ||
count(*) over(partition by parent_code) ||
')' as parent_info
from your_table
group by child_code
;What you need is called "string aggregation".
See here for various techniques, including the two above : http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php -
SQL - Multiple rows in a single column
Hi everyone,
I have a little question,
The result of my query looks like this:
VALOR
HERRERA
ANDREW
CHARLES
But I need they look like this:
VALOR
HERRERA - ANDREW - CHARLES
How I can do that without using PL/SQL?
Thanks for the help.Hi Justin,
Thanks for reply. The answer for your questions are:
1) No, sometimes could be 1 or 2 or 3 or....n
2) The true is that the result of the query have more columns. Here is the result of the query:
ID NAME VALUE SEC
150 ALGOMAS 44 1
150 AQWER 56456 1
150 DFDSF FG345143 1
150 GFDGDF 5433 1
150 TEST_123 HERRERA 1
166 ALGOMAS 22 1
166 AQWER 33 1
166 DFDSF 44 1
166 GFDGDF 55 1
166 TEST_123 ANDREW 1
243 ALGOMAS 1 1
243 AQWER 2 1
243 DFDSF 3 1
243 GFDGDF 4 1
243 TEST_123 WINDSOR 1
505 ALGOMAS VALOR DE CARAC 1
505 AQWER VALOR DE CARAC 1
505 DFDSF DDFDF 1
505 GFDGDF DFGG 1
505 TEST_123 HERRERA 1
505 TEST_123 CHARLES 2
505 TEST_123 ANDREW 3
If you see the three last rows, it repeat the NAME and the ID, What I need is that three records combine in one only row.
This is really a subquery, only need the VALUE column for the "big query", but when i execute the big query, i got the ORA-01427 error: single-row subquery returns more than one row. I know that error comes out because the NAME = TEST_123 in the ID = 505 have more than one value, so, if there is any way to put that values in only one rows, it resolve my problems.
3) Oracle Database 10g Release 10.2.0.1.0
I offer apologies if the initial information was not enough.
Once again, thanks for reply.
LCJ. -
I have external list where i want to apply multiple filter for every column like we do in Excel spreadsheet - we can filter a spreadsheet column by selecting multiple checkbox for every column. I am using Sharepoint 2010
Is this possible in sharepoint 2010? Any idea how to acheive that?
Thanks in advance.Hi Rahul,
According to your description, my understanding is that you want to use filter with multiple values on a column of an external list in SharePoint 2010.
Per my knowledge, there is not an OOB way to achieve it. As a workaround, you can custom the web part to implement it. There is an articles for your reference:
http://blogs.telerik.com/aspnet-ajax/posts/13-11-05/add-excel-like-multi-select-filtering-to-your-asp.net-datagrid
In addition, you can use a third party solution to achieve it, please take a look at:
http://abilitics.com/Blog/index.php/sharepoint-improved-grids-with-excel-like-inline-editing/
http://social.technet.microsoft.com/forums/sharepoint/en-US/3d19b9d3-d394-4af9-9e8e-2dee70b50540/filter-column-with-multiple-filter-values-in-sharepoint-list
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Concatenate multiple rows in a single column
Hi
I am using Web Intelligence v4.0x (i think) and I am hoping to get help.
My query (from Performance Management Module) has a field name called "Device Name" and it has two rows, server1 and server 2 (maximum of 33 servers)
I am trying to concatenate these values so that a blank cell in a report reads
"Devices are: server1, server2"
I am not able to concatenate server1 and server2 (i.e. get server1, server2) in the above statement. I've tried to use Previous(Self) and it does not work. I get output in two rows as
server1,
server2,
Any assistance or direction is appreciated.
Thanks - KevHi Jothi,
The solution that helped me earlier
"VAR1 =Replace(ReportFilter([Customer]);";";",")"
worked for one Customer ID that had two (or more) invoice# related to that Customer ID.
If there is more than one customer ID fetched by the query, the above solution merges all the related invoice# in that variable and does not merge invoice# per Customer ID.
E.g.
Customer ID Invoice ID
0001 P100
0001 P101
0002 P150
0002 P151
Desired Output
Customer ID Invoice ID
0001 P100, P101
0002 P150, P151
Actual Output: The query merges as:
Customer ID Invoice ID
0001 P100, P101, P150, P151
0002 P100, P101, P150, P151
and so on till the last customer ID is fetched.
Is it possible to tweak the query to obtain the Desired Output? Your help is appreciated.
Thanks - Kavan -
Multiple rows in a single column in a SQL statement
Can anyone provide me with a simple sql which will run on the below table (USERROLE table)
ID ROLEUSER ROLENAME
1 user1 GL
2 user2 OBI_AP
3 user1 OBI_AP
4 user2 GL
5 user1 OBI_AR
6 user2 AR
7 user3 GL
and give the result as
ROLEUSER ROLENAMES
user1 GL;OBI_AP;OBI_AR
user2 OBI_AP;GL;AR
user3 GL
Thanks
VikramIn 10g,
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:01.12
satyaki>
satyaki>
satyaki>with t2
2 as
3 (
4 select 1 id, 'user1' ROLEUSER, 'GL' ROLENAME from dual
5 union all
6 select 2, 'user2', 'OBI_AP' from dual
7 union all
8 select 3, 'user1', 'OBI_AP' from dual
9 union all
10 select 4, 'user2', 'GL' from dual
11 union all
12 select 5, 'user1', 'OBI_AR' from dual
13 union all
14 select 6, 'user2', 'AR' from dual
15 union all
16 select 7, 'user3', 'GL' from dual
17 )
18 select ROLEUSER ,
19 substr( string, 2 ) as string
20 from dual
21 where 1 = 2
22 model
23 reference t_ref
24 on
25 (
26 select row_number() over ( order by id ) - 1 as row_num ,
27 count(*) over () - 1 as max_row_num ,
28 ROLEUSER ,
29 ROLENAME
30 from t2
31 where ROLENAME is not null
32 order by ROLENAME
33 )
34 dimension by( row_num )
35 measures ( max_row_num, ROLEUSER, ROLENAME )
36 main t_main
37 dimension by ( cast( null as varchar2(4000) ) as ROLEUSER )
38 measures ( cast( null as varchar2(4000) ) as string )
39 rules
40 iterate( 4294967295 )
41 until
42 (
43 t_ref.max_row_num[0] is null or
44 iteration_number >= t_ref.max_row_num[0]
45 )
46 (
47 string[ t_ref.ROLEUSER[iteration_number] ] = string[ cv() ] || ';' ||
48 t_ref.ROLENAME[ iteration_number ]
49 )
50 order by 1;
ROLEUSER STRING
user1 GL;OBI_AP;OBI_AR
user2 OBI_AP;GL;AR
user3 GL
Elapsed: 00:00:00.26
satyaki>Regards.
Satyaki De. -
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
Maybe you are looking for
-
How do I turn on autofill/autocomplete in Pages 5.0?
I find the autofill/autocomplete feature in the tables very useful for when I'm filling out my forms for work. But ever since I updated to Pages 5.0 I can't seem to get the autofill to work in my tables any more. I don't want to simply copy and paste
-
How to change the Source system from ONE DataSource?
Hi, I'm trying to change a DataSource's source system (active with dtp and transfer rules), but it's not possible to do it in change mode because the field 'Source Sytem' is not enabled. I know I can use the BDLS transaction but I understand that th
-
Does Jheadstart retain Business logic after migrate from form9i
Hi I wish to do convertion from oracle form9i into Jheadstart MVC framework, I knew from doc, business logic can be emmbebed inside the Bc4j entities manually, but how far does jHradstart able to retain the original business logic inside those 9iform
-
3Com 3C905C-TX-M Fast EthernetLink XL 10/100
is this NIC always to crash or unstable? i'm using this card with my solaris 8 10/01, but no anything happen, how can i test my NIC is it running correct?
-
I have an error -42032 ?
I`ve just download itunes 10.6 and when launching an error message pops up -42032