Selecting /distributing column values
PQR A B C D E
AA 1 2 3 4
BB 1
CC 1 2 3
DD 1 2 3 4 5
EE 1 2
six columns PQR, A B C D E
Here in this table AA is a combination of 1 2 3 4 , similarly BB is 1 , CC is a combination 1 2 3 , DD is a combination of 1 2 3 4 5 , EE is a combination of 1 2
My new table will have a two columns PQR and ZZ with these values .
My final table will look like this , with all the combination values under a single column ZZ .
PQR ZZ
AA 1,2,3,4
BB 1
CC 1,2,3
DD 1,2,3,4,5
EE 1,2
How should the query be if I have to list each of these combination values under a single column and get rid of columns B C D E .
The resulting table should be in this order with 2 columns PQR and A
PQR A
AA 1
AA 2
AA 3
AA 4
BB 1
CC 1
CC 2
CC 3
DD 1
DD 2
DD 3
DD 4
DD 5
EE 1
EE 2
Any takers please.
Hi,
Type {code} (all small letters, between curly brackets) before and after tabular data when posting on this site, to preserve spacing.
I think what you want is:
SELECT SUBSTR ( CASE WHEN a IS NOT NULL THEN ',' || a END
|| CASE WHEN b IS NOT NULL THEN ',' || b END
|| CASE WHEN c IS NOT NULL THEN ',' || c END
|| CASE WHEN d IS NOT NULL THEN ',' || d END
|| CASE WHEN e IS NOT NULL THEN ',' || e END
, 2
FROM table_x;The CASE staements add only the items that are in the table, each preceeded by a comma. That keeps you from getting multiple commas when multiple columns are NULL.
SUBSTR removes the comma before the first item.
Edited by: Frank Kulash on Feb 4, 2009 5:13 PM
Similar Messages
-
How can i select other column values('-' separated) in group by function
CREATE TABLE EMP (
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
SAL NUMBER(7)
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7369, 'SMITH', 'CLERK', 800);
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7499, 'SMITH', 'SALESMAN', 1600);
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7521, 'ALLEN', 'SALESMAN', 2400);
In Output I want 3 columns : EMP,SUM(SAL),JOB(hyphenSeparated)
Means i want my output like
First row : SMITH,2400,CLERK-SALESMAN
Second row : ALLEN,2400,SALESMAN
I tried to write following sql : select ename,sum(sal) from emp group by ename
But i want other colummn value in '-' separated. but group by is only allowing agreegated function.
How can i select other column value using group by function.SQL> select ename,sum(sal), listagg(job, '-') within group (order by job) as job from emp group by ename;
ENAME SUM(SAL) JOB
ALLEN 2400 SALESMAN
SMITH 2400 CLERK-SALESMANnote: LISTAGG is a feature of 11.2 -
Filter a tableview based on a column value-Navigation Issues.
Hi,
I have a table view with total 99 values. The values are displayed in 10 tabs of the table view with 9 values in each tab.I go to the third tab and select a column value, which triggers an event and filters the result list from 99 to 12.
I am simply removing the collection and filling it again with fresh values.
My problem is-when i set the collection with new values, i want the end user to be navigated to the first tab.
But the user is always navigated to the second tab which has the last three values.
Is there any way to navigate the user to first tab of table view?
I have already tried-visibleFirstRow and it is not working.
Thanks and Regards,
RohitHi Ashish,
You can implement some code in DO_INIT_CONTEXT to filter your Items' BOL collection based on the condition quantity <> 0. I believe the Quantity field is available in the BOL structure.
Here is a code snippet.
DATA: lr_col TYPE REF TO if_bol_bo_col,
DATA: lr_node TYPE REF TO if_bol_bo_property_access.
lr_node = me->typed_context->CONTEXT NODE->collection_wrapper->get_first( ).
WHILE lr_node IS BOUND.
CALL METHOD lr_node->get_properties
IMPORTING
es_attributes = ls_struct.
IF ls_struct-quantity = 0 .
lr_col->remove( iv_bo = lr_node ).
ENDIF.
lr_node = lr_col->get_next( ).
ENDWHILE.
Regards,
Masood Imrani S. -
How to get column value of a selected row of ALV
Hello ,
I have application POWL POWL_UI_COMP uses another component POWL_TABLE_COMP.
This POWL_TABLE_COMP uses SALV_WD_TABLE.
I want to select value of ORDER id and it need to be passed whenever user selects a display order button(Which is self defined function generated in POWL_TABLE_COMP) . I am calling a display order on action of this display button(http://nap60.nalco.one.net:8042/sap/bc/webdynpro/sap/mt_order_app?IV_ACTIVITYTYPE=A&IV_EQUIPMENT=aaaa&IV_ORDERID=90001511&IV_ORDERTYPE=STD&IV_QMNUM=00&IV_TPLNR=00)
ORDERID is one column value of selected row of ALV table.
So please can you suggest , how to read ORDERID and pass it to the self defined function..
thanks in advance,
SharadaAnoop,
I have plcaed this code in event handler of on_lead_select.
Its giving error the element doesnt exist.
static_attributes should give me row data but it's giving short dump saying
Pl can you suggest.
data: set_of_element type WDR_CONTEXT_ELEMENT_SET,
element1 type ref to IF_WD_CONTEXT_ELEMENT,
result type POWL_CRESULT_STY,
table_helper type ref to CL_POWL_TABLE_HELPER,
context_node type ref to IF_WD_CONTEXT_NODE,
lt_selected_elements TYPE wdr_context_element_set,
static_attributes type ref to data.
table_helper = wd_comp_controller->mr_table_helper.
context_node = table_helper->get_data_node( ).
context_node = wd_comp_controller->mr_table_helper->get_data_node( ).
context_node->get_static_attributes( exporting index = r_param->index
importing static_attributes = static_attributes ).
thanks,
Sharada -
Weird ORA-01406: fetched column value was truncated error for SELECT query
DB version:10gR2
When one of our application fires the below query, we get
ORA-01406: fetched column value was truncatederror.
select trk_dtl,
trk_type,
trk_id,
trk_desc,
from shp_dtl
where shp_type = 'HN'
and shp_type = 828;The documentation says
Cause:In a host language program, a FETCH operation was forced to truncate a character string. The program buffer area for this column was not large enough to contain the entire string. The cursor return code from the fetch was +3.But when the application is pointed to an identical schema in the same instance, we don't get this error. So, this has got nothing to do client application as the documentation says.
Any idea what other possibilities are there?Post description of shp_dtl.
-
ORA-20001:Error fetching column value:Query must begin with SELECT or WITH
Hi all,
I have implemented an application with a master-detail form using Apex 3.1.2 and I imported that to Apex 3.2 on different server. Everything else seems to be fine except when I add detail record (clicking on Add Rows), I am getting following error.
=================
report error:
ORA-20001: Error fetching column value: ORA-20001: Query must begin with SELECT or WITH
====================
Both the databases have same version 10gR2. I didn't make any change after importing it as well. Can someone let me know what could be the issue? Thanks in advance.
SHYMay we know your first name?
Can you put the application in your workspace on apex.oracle.com so we can take a look?
Scott -
How to select each character of column value
Hi All,
How can i get each character separately of a column value in a select statement.
LIKE i emp table if ename='Test' then i want
a select statement that can give me the result like this
T,e,s,t
Regards,
Anil Ror this?
SQL> create table mytable
2 as
3 select 'test' text from dual union all
4 select 'a text, containing two comma''s (,)' from dual union all
5 select 'a text ending with a comma,' from dual
6 /
Tabel is aangemaakt.
SQL> select text
2 , substr(regexp_replace(text,'(*?)',',\1'),2,length(text)*2-1) with_commas
3 from mytable
4 /
TEXT WITH_COMMAS
test t,e,s,t
a text, containing two comma's (,) a, ,t,e,x,t,,, ,c,o,n,t,a,i,n,i,n,g, ,t,w,o, ,c,o,m,m,a,',s, ,(,,,)
a text ending with a comma, a, ,t,e,x,t, ,e,n,d,i,n,g, ,w,i,t,h, ,a, ,c,o,m,m,a,,
3 rijen zijn geselecteerd.Regards,
Rob.
Message was edited by:
Rob van Wijk
Slight modification to cater for strings beginning and ending with commas. -
Unable to pass report column value to url in select statement. Please help
Hi all,
I am trying to pass the report column value as follows:
select key, num,
case when Attachmentcnt(KEY) != 0 then
'f?p=&APP_ID.:91:&SESSION.:'' '':NO::P91_KEY,P91NUM,P91_PREVPG:'And I am passing values as follows:
{noformat}
'#KEY#,'#NUM#','9' ELSE null
END Attachment
from tableA
{noformat}
But, I am not able to figure out correct sysntax to pass these column values. Can anyone give me some help. I appreciate it.
rgds,
Suma.
Edited by: sumak on Jun 23, 2009 12:11 PM
Edited by: sumak on Jun 23, 2009 12:22 PMSuma,
If you're trying to generate a column with a URL, try something like the following:
select key, num,
case when Attachmentcnt(KEY) != 0 then
'f?p=&APP_ID.:91:&SESSION.:'' '':NO::P91_KEY,P91NUM,P91_PREVPG:'
|| tableA.key || ',' || tableA.num || ',' || :P91_PREVPG
else NULL
end
FROM tableA;
But the best way to pass these would include checksum values against the values of your parameters (to make sure a user doesn't hack them). You'll need to check the Apex User manual for details - See "Understanding Session State Protection".
Good luck,
Stew -
Multiple-Selection List Box Values in Multiple Columns
I am using InfoPath 2010 with SharePoint 2013. I have a form with a multiple-selection list box which has A LOT of choices. Instead of displaying all the choices in one column, is it possible to display the values of my list box in several
columns?Hi Andrea,
I agree with Brij, one multiple-selection list box is associated with one list field, we cannot use the one multiple selection list box value for other multiple selection list boxes, we need to create multiple choices for each multiple-selection list box
control in InfoPath form.
Thanks
Daniel Yang
TechNet Community Support -
Setting column values based on LOV selection
Hi All,
I am using JDeveloper 11.1.2.2.0. I have a table eg: Department table, in Dept Id, I have defined LOV for that field. My requirement is, based on the LOV selection, I want to set the other column values. I am using InputTextwithLOV in list type. How to achieve this?
I tried mentioning that in the List return values. But it is not setting the values.
Regards,
InfyHi,
if you use a model driven LOV then when configuring the LOV you can map additional attributes. When you build a model driven LOV you at least once tell it which LOV attribute should be used to update the DeptId field. You can do the same for additional attributes
Frank -
Crystal Reports XI - How to pull same column value with different select...
I have a report with many (around 30) sub reports and it is giving serious performance issue. I am currently finding out a strategy to improve the performance. I see that most of the sub reports are taking same parameters from main report except for one parameter which is different for each sub report and hard coded in them and pulling up the same column value from a oracle database with a different select criterion. I am trying to find out a way using either of command/crystal formula/SQL expression which can do the same job for me and give me performance improvement. I tried to take the parameters from the main report in one sub report and mapped them to parameters being transferred to the command and then drag and drop the field for which I need to display the value but due to some reason it is not returning values when I am trying multiple commands...I need some help in selecting a strategy for this issue resolution and some guidance....Any help would be highly appreciated....
My version is 11.5.8.826. First of all I need to make it clear that I have 6 set of sub reports and each set has 5 sub reports. So if I can resolve the issue for one set, I resolve it for all. The sub reports are doing nothing but fetching a column value using a simple SQL SELECT query and appending to the right of a box in main report. The issue is that all these queries embedded into the sub reports are using same SQL except for one parameter in the "where" clause and they are fetching same column value from the database and fortunately all of them are returning same number of results. So at the end these results create a table when run. The only way I can stop using sub reports is by creating a table in the main report and use some object(formula/command/SQL expression or whatever) to fetch that column value using the same filter conditions. But please take a note that I need to use and append the same column value from a database table and use different filter conditions and append them to the right so that at the end they create a table...as long as I get the table in the output with a decent performance , anyone will be least bothered about what I used inside the report.....please ask me as many questions to get more lights on the issue....
-
How to select 2column from 1 column values
Hi All,
How to select 2column from 1 column values
Ex : In Emp they have JOB column
JOB
CLERK
MANAGER
SALESMAN
MANAGER
MANAGER
ANALYST
PRESIDENT
SALESMAN
CLERK
CLERK
ANALYST
CLERK
here i want to get output like as follows
Ex: ejob1 ejob2
ANALYST SALESMAN
ANALYST SALESMAN
Can anyone helps me in this,it is urget
Thanks,Something like
select a.job, b.job from scott.emp a, (select job from scott.emp) b
CLERK CLERK
CLERK SALESMAN
CLERK SALESMAN
CLERK MANAGER
CLERK SALESMAN
CLERK MANAGER
CLERK MANAGER
CLERK ANALYST
CLERK PRESIDENT
CLERK SALESMAN
CLERK CLERK
CLERK CLERK
CLERK ANALYST
CLERK CLERK
SALESMAN CLERK
SALESMAN SALESMAN
SALESMAN SALESMAN
SALESMAN MANAGER
... -
Dynamically display title based on value selected in column selector
Hi All,
Can it be possible to show the report title dynamically based on value selected in column selector . suppose i have two column status and region . When i will select status in the column selector the title of the report will show " Status Summary" when i will select region then the title will change to "Region Summary". Please help me...Hi,
create dashboard prompt with column selector functionality like following way
write the following query in your dashboard prompt sql results
select region name from subject area name
Union all
select sub_region name from subject area name
like this and put one presentation variable for this dashboard prompt like var1
in your report write formula in your column like this *case when @{var1)='region column' then 'Region Summary' else ' ' end*
and refer this column in narrative view like @1 then narrative act like a title view.
Hope this helps you
Regards
Naresh -
How to select the larger value of column?
I would like a cell value (here E8) to be for example: (max $E$1:E7) + B8. Where all previous E column values were find the same calculation except for E1 that is a simple number and not a calculation? It does not work. It give the result for E1 + B8. The larger value should be E7. So the correct result should be E7 + B8 but if there is no value in E7 I want it to choose the larger number of the E column so far. Does some one can help me?
Hi Frederic,
If I understand "Where all previous E column values were find the same calculation except for E1", you want each cell, starting at E2 to contain this formula.
E2: =MAX($E$1:E1)+B2 E8: =MAX($E$1:E7)+B8
If that's the case, then "there is no value in E7" would never occur, and, unless the value of Bn were negative, the maximum value in column E would always be the one immediately above the formula.
In that case, this simpler formula would produce the same result:
E2: =E1 + B2 E8: =E7 + B8
Regards,
Barry -
Wrong values in distributed column in CJ40
Hi experts,
I am carrying out cost element planning in CJ40 against one child level wbs (level-2)and
also the cost is flowing from cProject to another child level wbs(level-2).
But after saving the costing data distributed amount at the parenet level WBS should be sum of two individual WBS element cost.
But here in my case , system is showing the cost element data in distributed column and not considering the cost whic flows to costing column and this amount is shown in distributable column.
can anybdy suggest any solutn for the same.
Regards
AshisHi Ashis,
This is the standard behaviour. It is similar you plan costs in PS using easy cost planning. You can see yoou cost total up or in a report or go to CJ20N -->open your project --> SHIFT + F11
Regards,
sara
Maybe you are looking for
-
Issues with Bootcam 3.0 on OSX 10.6.2
Hi, I recently got MBP (mid 2009 version) which came with Bootcamp 3.0; I've updated the software to 10.6.2 & tried to install win XP using boot camp, all went fine but I noticed that the red LED of the audio port would stay on; searching here, I cam
-
About EFI development with Visual Studio
Hi all! Please help me about this problem issue bellow. I 'm developing for a demo application about UEFI and EFI technology. I using EFI_Toolkit_2.0 to build this demo follow some step on command line of Visual Studio from 2005 to 2010 , on Win7 32
-
Downloading mountain lion paused. How do I resart it?
During the downloading of mountain lion it paused. How do I get it to restart?
-
Looking for interMedia web sites using text retrieval
I'm looking for web sites which use interMedia to support their site search function. My goal is to evaluate intermMedia for use as a full text search engine. I'm particularly interested in sites which use the thesaurus features. Thanks.
-
How to store graphics 2d as buffered image
Hi, as per my requirement i need to generate a diagram and store it as a image. for that i am using bufferedimage class to create and draw the image by specifying the width and height. but some times the data migth be more than the height specified.