How to get rows values in a column only ?
How to get all returned values in rows in a column.
e.g., a query gives output as :
123
234
233
12121
all in different rows. But i want the result like this:
123,234,233,12121.All in a single row and a single column .
How is this possible ?
prakash wrote:
hi ,
Use the following example
CREATE or replace FUNCTION fn_return_row
RETURN VARCHAR2
IS
v_row VARCHAR2 (32767);
BEGIN
FOR curr_row IN (SELECT ename
FROM emp11)
LOOP
v_row := v_row ||','|| curr_row.ename;
END LOOP;
RETURN v_row;
EXCEPTION
WHEN OTHERS
THEN
RETURN NULL;
END fn_return_row;
select fn_return_row from dual ;Thanks,
P PrakashThere's no need to use PL/SQL when SQL provides adequate functionality to do it.
The title of the thread is misleading as turning rows into columns is called pivoting, but the description of the issue wanting to join all the rows together into a single column, is actually called string aggregation.
As already demonstrated it can be done several ways.
1. with XML functionality
2. using the SYS_CONNECT_BY_PATH method
and if you have 11gR2, there's...
3. the new LISTAGG analytical function.
There is also an undocumented WMSYS.WM_CONCAT function, though this isn't as flexible as other methods in that you can't control the order of the aggregated data so easily, and using such undocumented functions in production code is dangerous, as the functionality could change in future versions of Oracle, as well as it's use making your code such that Oracle will not provide support if the code with issue is using it.
Similar Messages
-
"How to get distinct values of sharepoint column using SSRS"
Hi,
I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>{GUID of list}</DefaultValue>
</Parameter>
<Parameter Name="viewName">
<DefaultValue>{GUID of listview}</DefaultValue>
</Parameter>
<Parameter Name="rowLimit">
<DefaultValue>9999</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
I would really appreciate if anyone can help me out with this.
Thanks,
Sam.Hi Sam,
By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
In this case, we could use the custom code to get distinct records.
Here are the detailed steps:
1. Create a hidden parameter that gets all the records in one field.
Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
2. Create a function that used to remove the duplicate records.
Here is the code:
Public Shared Function RemoveDups(ByVal items As String) As String
Dim noDups As New System.Collections.ArrayList()
Dim SpStr
SpStr = Split(items ,",")
For i As Integer=0 To Ubound(Spstr)
If Not noDups.Contains(SpStr(i).Trim()) Then
noDups.Add(SpStr(i).Trim())
End If
Next
Dim uniqueItems As String() = New String(noDups.Count-1){}
noDups.CopyTo(uniqueItems)
Return String.Join(",", uniqueItems)
End Function
3. Create another parameter that will be used for filtering the maindata.
Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
And the default value to be the value you what such as the first value:
=Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
4. Go to the main dataset. Open the property window of this dataset.
5. In the “Filters” tab, set the filter to be:
Expression: <The field to be filter>
Operator: =
Value: =Parameters!Region.Value
The parameter “Region” should be the parameter we created in the step3.
Now, we should get distinct values of SharePoint columns.
If there is anything unclear, please feel free to ask.
Thanks,
Jin
Jin Chen - MSFT -
How to get a value from a column inside a table
Hi,
I have got the following problem. I have got a table with some data inside. And a new column, which is not in the dataprovider. Now i search for an opportunity to go through the rows of the table and check the value of this column. I cant do this with the dataprovider or the rowset. My question is now how can i do this? The table object doesnt seem to have a corresponding method.
Thanks in advance for help
Acinonyxthis is some code you can use (based on Winston's and others' tips):
put this in you page bean:
private HashSet selectedRows = new HashSet();
public boolean isSelected() {
TableRowDataProvider trdp = (TableRowDataProvider)getBean("currentRow");
if (trdp == null) {
return false;
RowKey rowKey = trdp.getTableRow();
if (this.selectedRows.contains(rowKey.getRowId()))
return true;
else
return false;
public void setSelected(boolean b) {
TableRowDataProvider trdp = (TableRowDataProvider)getBean("currentRow");
RowKey rowKey = trdp.getTableRow();
if (checkbox1.isChecked()) {
this.selectedRows.add(rowKey.getRowId());
Object v = this.t_fotoDataProvider.getValue("fieldName", rowKey);
} else {
this.selectedRows.remove(rowKey.getRowId());
and then bind the "selected" property of the checkbox column to the "selected" property of the page bean.
Now, eveytime the page is submitted, you can do something useful, for example, in the setSelected() method (the row that starts with Object v = ... get's the value of some field corresponding to the checked row)
Mauro -
How to get the values in separate columns
Hello Everyone
I am new to Bex, i have the sales data of 2008,2009,2010. now i have to display the sales order(key figure) for 2008,2009,2010 in separate columns for each customer(dimension) in a single report , can any one help me how to get this done in bex.
Thanks
GuptaHi ,
You can achieve this either creating New Selections or Restricted Key Figures.
Right click on the structute>>>> New selcection>>> drag the year to right [ Right Click on it >>restrict it with 2008}>>>Drag the respected Key figure.
So u will get the values 2008 in seperate column.
COpy the New Selecten that u created and paste on the structure , chage the descriprion and year to 2009.
do the same for 2010.
Note:you can also achieve this by creating variable offsets.Check the following link
http://help.sap.com/saphelp_bw33/helpdata/en/3f/89533e5ff4d064e10000000a114084/content.htm
Regards,
Ranganath -
How to get max value of a column in VO?
Hi ,
i need to find the max value of a column named insured value in VO.
Please help!!Hi,
If this value is cuming from the Query then u can easily go for MAX function. If its a user enterable value then u need to iterate through all the rows for that column to find the max of them.
Let me know.
Regards,
Gyan -
How to get rows where a varchar column contain pure numeric value
hi,
i have to make a query from a table that return only the rows where the occurrences of a string column contain a pure numeric value
for example my table MYTABLE have the column COL1 varchar2(100)
with values
row 1 : '100'
row 2 : '101 dalmatiens'
row 3 : '102'
row 4 : 'anything'
i want to get only the rows 1 and 3 which are pure integer so i can sort and compare them like number.
thanksSQL> with rt as
2 (select '100' str from dual union all
3 select '101 dalmatiens' from dual union all
4 select '102' from dual union all
5 select '103 #$&''() 456' from dual union all
6 select 'anything' from dual)
7 /* End of sample data (rt) */
8 select str
9 ,trim(translate(str,'1234567890'||str,'1234567890')) num
10 from rt
11 where trim(translate(str,'1234567890'||str,'1234567890')) is not null;
STR NUM
100 100
101 dalmatiens 101
102 102
103 #$&'() 456 103456
-- Oooooops, I misread and now have corrected it
SQL> with rt as
2 (select '100' str from dual union all
3 select '101 dalmatiens' from dual union all
4 select '102' from dual union all
5 select '103 #$&''() 456' from dual union all
6 select 'anything' from dual)
7 /* End of sample data (rt) */
8 select str
9 ,trim(translate(str,'1234567890'||str,'1234567890')) num
10 from rt
11 where trim(translate(str,'1234567890'||str,'1234567890')) = str;
STR NUM
100 100
102 102Message was edited by:
ushitaki -
How to get Maximum value in one Column
Here example
I have table with one column named as "Title" i want the result as which data length in "Title" is more than 2.
Title
AAA
A
AAAAA
AA
i want result as :
AAAAA
AAA
Thankx in Advanceselect title from <tab> where length(title) > 2;
You could also use dump(title) to get the internal representation and length.
Message was edited by:
Stellios -
Need to get sequence value in another column in oracle
Hi ALL,
I have sql query as below
select header_id,order_number from oe_order_headers_all.
and data it is displaying as
heder_id order_number
111 500001
121 500400
I need to display another field with some sequence value like as below
id heder_id order_number
1 111 500001
2 121 500400
so how to get sequence value in another column please help me on this.
ThnaksYou can just use ROWNUM Pseudocolumn
select rownum id, header_id,order_number from oe_order_headers_all -
How can I get the value of "Warehose" column in a form
How can I get the value of "Warehouse" column in the form below (I mean what table that contain this value):
Production Supervisor >> Batches >> (Button) Material Details >> (Button) Line Allocations
Well, for more clearly! My problem is I must have the Unit Cost of Items, so I've got it in the cm_cmpt_dtl (table), but if I want to, I must create a relation that require 2 filed, they're Item_ID and Whse_Code.
There's no problem with Item_ID, but Whse_Code seem to be the Mission Impossible (hix, I hate that film!!!!)
I wonder if It was right to post this topic here. But anyway I just post my question here, hope I could get some help.wow, many, many, many.... and many thanks!
Just add a tiny modify to check out the Batch_type
doc_id = (select batch_id from gme_batch_header where batch_no='&batch_number' and batch_type = 0)
Because the batch_no can be duplicated as we also create Batch and Filrm Planned Order.
Many thanks for your support!
P/S: Sorry for my terrible English :P -
How to use row values in Presentation or Administration for calculation
Hi All,
I am working on OBIEE, I want to calculate / or % on two rows.
e.g. In my report row 3 is value 20 and row 5 is value 200.
In same column row 6 I want to display *(row 5 / row 3 )* 200/ 20 i.e. output should be 10.
Else can I use variable to and assign value to variable.
I tried but giving error :
CASE
WHEN "Report Structure".Seq = 101 and Currency.Code = 'SAR' THEN
"Fact Report"."Actual PTD" ,
VALUEOF("col10") = "Fact Report"."Actual PTD"
ELSE "Fact Report"."Actual PTD"
END
I am trying to store row value to repository variable to solve above problem.
My question is how to assign value to variable.
Please guide me to solve this problem.
Thanks In advance
Regards
DixitWhen you want to compare two row values, you can use the lag and lead analytical function of oracle.
lag and lead are analytical functions that can be used to get the value of a column in a previous/next row.
I have made just an example on my blog for a period to period comparison on OBIEE
http://gerardnico.com/weblog/2009/04/17/obiee-period-to-period-comparison-with-the-analytical-function-laglead/
And if you want an example on Oracle :
http://gerardnico.com/wiki/dw/analytic_function/analytic_function_lag
But I don't understand completely your problem. What about the row 1, 2, 4 ? I don't really see you report.
What I see, is that you have a problem with the currency.
You say :
I am trying to store row value to repository variable to solve above problem.For me, it's not possible...
Success
Nico -
How to get length of data on column with long datatype
How to get length of data on column with long datatype without using pl/sql block
...another reason not to use LONG datatype for columns.
Oracle advises to switch to LOB columns instead
SQL> create table t
2 (x long)
3 /
Table created.
SQL> insert into t values (rpad ('x', 10000, 'x'))
2 /
1 row created.
SQL> alter table t
2 modify x clob
3 /
Table altered.
SQL> desc t
Name Null? Type
X CLOB -
How to get the values from popup window to mainwindow
HI all,
I want to get the details from popup window.
i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
now i am able to display popup window with values.How to get the values from popup window now.
I can anybody explain me clearly.
Thanks&Regards
kranthiHi Kranthi,
Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
Regards,
Uday -
Get millisecond values from timestamp column in v$logmnr_contents
Hello
How do we get millisecond values from timestamp column in v$logmnr_contents.
I tried with following query.
select scn,To_Char(timestamp,'DD-MON-YYYY HH24:MI:SS:FF') from v$logmnr_contents WHERE OPERATION NOT IN('START') and username ='SCOTT' and sql_redo is not null and (seg_owner is null or seg_owner not in('SYS'));
it says ORA-01821: date format not recognized. I want to find the relation of scn with timestamp. In forums i found, scn is derived from timestamp value. I dont know its correct or not.
if i query with out FF in time format i get like
scn timestamp
808743 27-NOV-2007 00:12:53
808743 27-NOV-2007 00:12:53
808743 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
if scn is derived from timestamp with milliseconds, each scn should be different right?More help pleaseMay be there's an easy way solving your problem, I did it like that:
CREATE TABLE quota_test (test VARCHAR2(50))
INSERT INTO quota_test
VALUES ('update "SCOTT"."NEWTAB1" set a="34" and b="45"')
SELECT test normal, REPLACE(SUBSTR(test,INSTR(test,'"',1),INSTR(test,'.',1)+2),'"','') changed
FROM quota_test
Result is :
NORMAL
update "SCOTT"."NEWTAB1" set a="34" and b="45"
CHANGED
SCOTT.NEWTAB1
If you didn't understand, I can explain what I wrote -
How to get selected value from selectOneRadio ???
Hi...i want to how to get selected value from selectOneRadio and use it in another page and in backing bean.
Note i have about 10 selectOneRadio group in one page i want to know value of each one of them.
Plzzzzzzzz i need helpYou have a datatable in which each row is a question, correct?
Also in each row you have 5 possible answers that are in a radio, correct?
So,
You need to put in your datatable model, a question, and a list of answers (5 in yor case) and the selected one.
So you will have a get to the question, an SelectItem[] list to populate the radios and another get/set to the selected question.
ex:
<h:selectOneRadio value="#{notas.selectedString}" id="rb">
<f:selectItem itemValue="#{notas.valuesList}"/>
</h:selectOneRadio>
Search the web for examples like yours. -
How to get attribute value from standard page ?
Hi,
How to get attribute value from standard page ?
String str = (String)vo.getCurrentRow().getAttrbute("RunId");
But this value is returning a null value ....
Can anyone help me to get this attribute value which is actually having a actual value .getCurrentRow() would always return null if no setCurrentRow() is used.
Please check the page design and understand how many rows of VO are there. You can also use the following to get the row:
vo.reset();
vo.next();
Regards
Sumit
Maybe you are looking for
-
How do I change the way itunes stores my music?
When I look at my music library in the finder my itunes music is stored totally different than the way I have it in my itunes source list. This is creating annoyances for using front row for me. I want front row to organize my music exacty as I have
-
HP C5280 Photosmart All-in-One inkjet printer
I've owned my C5280 inkjet printer for almost 3 years and like my previous inkjet printer, a Deskjet 895Cse I can print different kinds of documents, envelopes, etc. but one thing I have not been able to print on are No. 6 envelopes. For those who d
-
Vendor with Bank details - How to replicate?
Hi guys, I need help for replicating Vendor bank details. I`m transferring vendors by BBPGETVD, but the bank details don`t go to SRM. I have tried to transfer basic data by R3AS where the object name is DNL_CUST_BNKA, didn`t work as well. I`m using t
-
I need help with Abobe Reader XI or Acubat.
I have purchased a new computer and Abobe Reader XI nor Acubat will work. I get the message "Adobe has stopped working". I only get to step 1 of 3 and disable my ESET Smart Security 8 Firewall and Protection. Please Help.
-
Light Room 4 and dark circles under eyes
How to get rid of dark circles under the eyes?