How to join 2 rows under single column header
i want to join 2 or more rows under a single column header. as shown "container details" is the column name with "h", "w", and "s" and the sub column names. so my header should contain all these four names and my 3 rows under h,w and s should be clubed under this container details.
anyone help me out. thanks in advance.
container details
| h | w | s
Bummer, I just tried the link (which I saved from a couple months ago) and it doesn't work. This was a great site for showing how to do various things in Swing. Sorry for the bad link. Maybe someone saved the sites info or knows where it may have moved. Dang...
Similar Messages
-
How to convert rows into single columns in Oracle?
I have table with data like shown below in Oracle database.
P_COLUMN
COLUMN_1
COLUMN_2
COLUMN_3
COLUMN_ 4
COLUMN_5
COLUMN_6
COLUMN_7
COLUMN_8
COLUMN_9
COLUMN_10
1
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
1
B1
B2
B3
B4
B5
B6
B7
B8
B9
B10
1
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
2
AA1
AA2
AA3
AA4
AA5
AA6
AA7
AA8
AA9
AA10
2
BB1
BB2
BB3
BB4
BB5
BB6
BB7
BB8
BB9
BB10
I need a query to get one row based on P_COLUMN's value i.e. for P_COLUMN =1, below should be output :-
C_1
C_2
C_3
C_4
C_5
C_6
C_7
C_8
C_9
C_10
C_11
C_12
C_13
C_14
C_15
C_16
C_17
C_18
C_19
C_20
C_21
C_22
C_23
C_24
C_25
C_26
C_27
C_ 28
C_29
C_30
C_31
1
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
B1
B2
B3
B4
B5
B6
B7
B8
B9
B10
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
2
AA1
AA2
AA3
AA4
AA5
AA6
AA7
AA8
AA9
AA10
BB1
BB2
BB3
BB4
BB5
BB6
BB7
BB8
BB9
BB10
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
i searched google and found PIVOT, CROSS JOIN etc but could not use those keyword properly.
Thanks in advance.
Note - My DB client version is 11g.Since you have 11G, here's an alternative with the PIVOT clause.
First, set up test data with up to 10 rows:
CREATE TABLE T(P1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10) AS SELECT
1,1,2,3,4,5,6,7,8,9,10 FROM DUAL;
INSERT INTO T
WITH DATA AS (SELECT LEVEL*10 N FROM DUAL CONNECT BY LEVEL <= 9)
SELECT P1, C1+N, C2+N, C3+N, C4+N, C5+N, C6+N, C7+N, C8+N, C9+N, C10+N
FROM T, DATA;
INSERT INTO T
SELECT P1+1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
FROM T
WHERE C1 <= 11;
select * from t order by p1,c1;
P1
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
1
1
2
3
4
5
6
7
8
9
10
1
11
12
13
14
15
16
17
18
19
20
1
21
22
23
24
25
26
27
28
29
30
1
31
32
33
34
35
36
37
38
39
40
1
41
42
43
44
45
46
47
48
49
50
1
51
52
53
54
55
56
57
58
59
60
1
61
62
63
64
65
66
67
68
69
70
1
71
72
73
74
75
76
77
78
79
80
1
81
82
83
84
85
86
87
88
89
90
1
91
92
93
94
95
96
97
98
99
100
2
1
2
3
4
5
6
7
8
9
10
2
11
12
13
14
15
16
17
18
19
20
Now the SELECT statement using PIVOT:
SELECT * FROM (
SELECT T.*,
ROW_NUMBER() OVER (
PARTITION BY P1
ORDER BY C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
) RN
FROM T
PIVOT(
MAX(C1) C1, MAX(C2) C2, MAX(C3) C3, MAX(C4) C4, MAX(C5) C5,
MAX(C6) C6, MAX(C7) C7, MAX(C8) C8, MAX(C9) C9, MAX(C10) C10
FOR RN IN (1 R1,2 R2,3 R3,4 R4,5 R5,6 R6,7 R7,8 R8,9 R9,10 R10)
P1
R1_C1
R1_C2
R1_C3
R1_C4
R1_C5
R1_C6
R1_C7
R1_C8
R1_C9
R1_C10
R2_C1
R2_C2
R2_C3
R2_C4
R2_C5
R2_C6
R2_C7
R2_C8
R2_C9
R2_C10
R3_C1
R3_C2
R3_C3
R3_C4
R3_C5
R3_C6
R3_C7
R3_C8
R3_C9
R3_C10
R4_C1
R4_C2
R4_C3
R4_C4
R4_C5
R4_C6
R4_C7
R4_C8
R4_C9
R4_C10
R5_C1
R5_C2
R5_C3
R5_C4
R5_C5
R5_C6
R5_C7
R5_C8
R5_C9
R5_C10
R6_C1
R6_C2
R6_C3
R6_C4
R6_C5
R6_C6
R6_C7
R6_C8
R6_C9
R6_C10
R7_C1
R7_C2
R7_C3
R7_C4
R7_C5
R7_C6
R7_C7
R7_C8
R7_C9
R7_C10
R8_C1
R8_C2
R8_C3
R8_C4
R8_C5
R8_C6
R8_C7
R8_C8
R8_C9
R8_C10
R9_C1
R9_C2
R9_C3
R9_C4
R9_C5
R9_C6
R9_C7
R9_C8
R9_C9
R9_C10
R10_C1
R10_C2
R10_C3
R10_C4
R10_C5
R10_C6
R10_C7
R10_C8
R10_C9
R10_C10
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 -
How to add multiple columns to single column header
hi,
i wans to add two columns under a single column header in jtable how can i do this.By following some of these clever samples:
http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples1.html
Lots of different ideas on manipulating headers and columns there and on the proceeding pages. -
How to return a record's column head given a record of a table.
Hi:
Do you know how to return a record's column head given a record of a table.
For example, in a table with 3 columns "ID", "Education", "Age".
Give you the record "Bachelor", how can you use a SQL to return the correspondent column head "Education"?
Thanks for the big help.Have a look at http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSetMetaData.html.
import java.sql.*;
import java.util.*;
ResultSet rs = stmt.executeQuery("SELECT * FROM testTable");
ResultSetMetaData rsmd = rs.getMetaData();
// loop through rsmd.getColumnCount() {
String columnName = getColumnName(i);
// run a query SELECT * FROM testTable WHERE columnName='Bachelor'
// if rs !=null return columnName and break out of the loop
} -
Hi All,
Question: How do I filter rows out of a query where multiple columns are equal to a single question mark character?
Background: I'm using SQL 2008 R2. Furthermore, the part of my brain that helps me create less-than-simple queries hasn't been working for the last 4 days, apparently, and now I need help.
We have about 4,000 rows in a table. This data set was generated from an exported report, and many of the rows in the detail table were not actual data rows but were simply "header" rows. For those table rows, most of the columns have
a single question mark as the value.
Some of the detail rows have one or more question mark values, too, so it's important that these rows don't get filtered out.
When I include criteria like "WHERE col1 <> '?' AND col2 <> '?' AND col3 <> '?' AND col4 <> '?'", all rows with a question mark value for even a single one of those columns get filtered out. How do I filter out rows
where all columns 1-4 contain a question mark value?
Thanks for your help,
EricI just tried to create to create a scenario for you. Please see ig you're looking for something like this.
Create table test_Question_mark
RecordID INT identity(1,1),
Col1 varchar(10),
Col2 varchar(10),
Col3 varchar(10),
Col4 varchar(10),
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','?','?')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','??','?')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','??','??','??')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ??','??','??')
insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ?','??','??')
--drop table test_Questio_mark
select * from test_Question_mark
select * from test_Question_mark
WHERE
(CHARINDEX('?', Col1,1) > 0 AND CHARINDEX('?', Col1, CHARINDEX('?', Col1,1)+1) = 0) AND
(CHARINDEX('?', Col2) > 0 AND CHARINDEX('?', Col2, CHARINDEX('?', Col2,1)+1) = 0) AND
(CHARINDEX('?', Col3,1) > 0 AND CHARINDEX('?', Col3, CHARINDEX('?', Col3,1)+1) = 0) AND
(CHARINDEX('?', Col4,1) > 0 AND CHARINDEX('?', Col4, CHARINDEX('?', Col4,1)+1) = 0)
--drop table test_Questio_mark
I hope above solution will help.
Thanks!
Ashish. -
How to grey out one single column in a table control of TPMOE
Hi Experts,
Any body please tell me how to greyout a single column in a table control of TPMOE.
Help needed ASAP.
Thanks,
sreenivas.lr_result TYPE REF TO if_bol_bo_property_access
lr_iterator TYPE REF TO if_bol_bo_col_iterator
CALL METHOD lr_iterator->get_by_index
EXPORTING
iv_index = index
RECEIVING
rv_result = lr_result.
CALL METHOD lr_result->get_property_as_value
EXPORTING
iv_attr_name = 'TRANSFER_STATUS'
IMPORTING
ev_result = lv_status.
if lv_status = x and component = cost_category.
rv_disabled = true.
else.
call super.
endif.
INDEX will have the row number.
Frame ur logic based on this. -
Hi All
Need some assistance, i have a table where i want the output to be a single column
ex: select from t1;*
query output_
rownum col_1
1 8217
2 6037
3 5368
4 5543
5 5232
i would like the result to be : *8217,6037,5368,5543,5232*
thanks for your help in advance.
i did look on the web but can't find a solution that is easily understood.Hi,
855161 wrote:
thanks for responding quickly.
the link example seems not to work for me:
below is the information you have requested:Below is some of what I requested. The CREATE TABLE and INSERT statements seem to be missing.
1. duplicate values have no effect
2. list doesn't need any order
3. Version 10.2.0.5.0 For that, I recommend the user-defined aggregate function called STRING_AGG in the Oracle Base page, but called STRAGG by most of the people who use it. You have to copy and run about 60 lines of code from the Oracle Base page, or from AskTom one time, but once you have it installed, the job is as simple as
SELECT MIN (rnum) AS rnum -- ROWNUM isn't a good column name, since it's the same as a pseudo-column
, STRAGG (count_1) AS count_1_list
FROM table_x
;Hundreds of other jobs you have in the future will be just as easy, and you won't have to go through the installation process again.
Relevant information:
1. table columns : count_1
all rows should become a single row with ',' in between
example:
select * from t1;
output:
Rownum count_1
1 8217
2 6037
3 5368
4 5543
5 5232
Desired results :
Rownum count_1
1 8217, 6037, 5368, 5543, 5232
Edited by: 855161 on Dec 11, 2012 1:25 PMThe main problem with STRAGG is that it doesn't create a list in order. You said that's not an issue in this case, but if you ever do need output in order, then the best option in Oracle 10 is the SYS_CONNECT_BY_PATH technique. The main Oracle-Base page shows how to use SYS_CONNECT_BY_PATH in Oracle 9. Of course, that works in all later versions too, but in version 10 a simpler way, using CONNECT_BY_ISLEAF, became available. See the Oracle-Base Comments Page for the eaiser Oracle 10 technique. -
Problem in Adding two buttons under same column header (in JTable)
Hi,
I have a JTable and to a particular column i want to add two buttons.
Here the two buttons should be under the same column header and i need to add listners to these.
Any idea how to do this?
Thanks & regards
NeelOf course as your header is drawn by a renderer, the buttons don't actually work, but you can listen for mouse clicks within the area of the header and see which button the mouse position was over.
See the Java Table Sorter Demo code for how to add a mouse listener to the header...
http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html#TableSorterDemo
....and from there you should be able to determine where in the component the click occured by using the getX() and getY() methods of the MouseEvent to determine which button in the renderer component was clicked. Use something like Rectangle.contains() to match the click location against the buttons. -
How to suppress row when one column has zero using condition
Hi Experts,
How do I suppress row when one column has zero.
I read it is possible using conditions.
How ?
Thankyou.Check this
1. for Query Properties, go to the Display tab and Supress Zeros is "Active"
2. select the Structure, right-click, select Properties, then click "on" Also Use Zero Suppression for Structure Elements
http://help.sap.com/saphelp_nw04/helpdata/en/a4/dd3841d132d92be10000000a1550b0/frameset.htm
Hope it Helps
Chetan
@CP.. -
How to avoid WRAP of EXCEL Column HEADER Fields
We have 3 tablix in the rdl file with 11 inch * 8.5 inch (to print in A4)
Tablix 1 - HTML viewer
Tablix 2 - EXCEL
Tablix 3 - PDF
The size of the rdl is fixed , if size altered then printing becomes an issue.
So we have to keep the rdl size fix
but at the same time the WRAP of column header of the EXCEL need to be avoided ,
because if the size of the column header is not reduced then we cannot be able to accomodate in the defined page size
Eaxmple of SOme Header Field Name
1.OccupationCode
2.ChargeJobPhase which are quiet large fields, so it need to be wrapped(to reduce the length of the column to accomodate ) to fit in the page.
So as an Alternative option I use the COncept of Subreport and called it by adding row outside group otherwise the
Report Server treats subreport as new report for each instance of the parent report.
The challenge we faced is when export to EXCEL some of the columns is getting merged , I believe the size of the child report (sub report) is having the length
greater than the parent report (Called Report ) and the size has to be large otherwise the COLUMN HEADER need to reduced which makes it Wrapped
So is there any alternative without changing the parent report size and without WRAPPING the HEADER text of CHild report the MERGING of cell can be avoided.
Since MERGING is happening which is not allowing us to PUT FILTER in EXCEL but we need to have FILTER applicable since the END user use it to sort, find the records.Hi SubhadipRoy,
In Reporting Services, whether to wrap text or not is depended on the CanGrow property. If we set the CanGrow property of tablix header row to true, then the header row of tablix will be expanded. If we set the CanGrow property of tablix header row
to false, the header row will be shrunk as the designed size.
So if we want to avoid wrap text, we can try to set the CanGrow property of tablix header row to false in Reporting Services level. Alternatively, we can click the Wrap Text button to enable the expended extra-long text property in Excel level.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to dynamically display value in column header
Hi,
I have a requirement where in the user selects a particular value from a drop down list, and the same has to be displayed in the column header. For example, there are A,B,C,D types of quantities in a drop down list. Once the user selects these values and submits, the column header should display the quantity type selected. Kindly let me know how this can be achieved.
Regards
Snehith.Hi Snehith,
In Layout Mode, Double click the Column in the Table, the Control Properties window is opened, switch to the "Display" tab, then press on the formula button next to the "Label:".
Use the Expression Builder to have the label be the value you want it to be: for example:
NSTR(#ID[ACA9TU]@MAX_ROWS,'Z3.0')
This formula takes a numeric field, formats it into a string and displays it.
For more information about how to build expression, please see:
http://help.sap.com/saphelp_nw70/helpdata/en/bd/90db4238bbf140e10000000a1550b0/frameset.htm
Regards.
Omer. -
How to convert Rows to different columns
Hi All,
I am having a table address with the following data.
ID REL_NAME REL_RELATION REL_PHONE
1--- kish_rel1--- wife--- 1111
1--- kish_rel2--- sister--- 2222
1--- kish_rel3--- brother--- 3333
2--- ram_rel1--- brother--- 4444
Now i want to display rows data into columns. See the output i want. Exactly, I dont know how many rows are there for each ID. It may increase or decrease.
ID REL_NAME REL_RELATION REL_PHONE
1---kish_rel1--- wife--- 1111---kish_rel2--- sister--- 2222---kish_rel3--- brother--- 3333
2---ram_rel1--- brother--- 4444
Thanks in advance,
PalHi,
I have found this is useful. But it is static. It wont work if we dont know the maximum number of rows present when grouped by ID.
Is there any other solution, which will give correct values, if we dont know the row count when grouped by ID.
SELECT hrid,
MAX(case when seq=1 then rel_name end) AS "rel_name1",
MAX(case when seq=1 then rel_relation end) AS "rel_relation1",
MAX(case when seq=1 then rel_phone end) AS "rel_phone1",
MAX(case when seq=2 then rel_name end) AS "rel_name2",
MAX(case when seq=2 then rel_relation end) AS "rel_relation2",
MAX(case when seq=2 then rel_phone end) AS "rel_phone2",
MAX(case when seq=3 then rel_name end) AS "rel_name3",
MAX(case when seq=3 then rel_relation end) AS "rel_relation3",
MAX(case when seq=3 then rel_phone end) AS "rel_phone3",
MAX(case when seq=4 then rel_name end) AS "rel_name4",
MAX(case when seq=4 then rel_relation end) AS "rel_relation4",
MAX(case when seq=4 then rel_phone end) AS "rel_phone4"
FROM (SELECT hrid, rel_name, rel_relation, rel_phone, ROW_NUMBER() over(partition by hrid ORDER BY hrid) AS seq FROM address)
GROUP BY hrid
Thanks,
Pal -
How to transpose rows into multiple columns using pivot table
I have 1 row containing 12 columns with value "JAN", "FEB", "MAR", "J-1","F-1","M-1","J-2","F-2","M-2","J-3","F-3","M-3"
I want to display as
JAN J-1 F-1 M-1
FEB J-2 F-2 M-2
MAR J-3 F-3 M-3
How do I achieve the above?Today you have only 3 months JAN, FEB, MAR. Is it always the same number of columns. What if there are more months added to this row?
Is your data really coming from relational source or some sort of text file?
There is a better way to do this in narrative view using HTML if your requirement is just to show them in multiple rows and do some calculations.
Go to Narrative View;
In prefix, use <html> <table>
In 'Narrative' text box add something like this
<tr> <td> @1 </td> <td> @4 </td> <td> @7 </td> </tr>
<tr> <td> @2 </td> <td> @5 </td> <td> @8 </td> </tr>
<tr> <td> @3 </td> <td> @6 </td> <td> @9 </td> </tr>
In Suffix, use </table> </html>
You can also add simple calculations like sum etc at the very bottom of these rows as grand totals.
kris -
ALV column header with multiple rows and ALV column header span
How could I have in an ALV a column header on several lines and/or a column header that spans on multiple columns?
i.e. I would like to have in an ALV two columns, each with it's own distinct header and additionally another column header for both of the columns, that spans across both columns. How could I program this?Hi,
follow below mentioned code
SET THE LABEL OF THE COLUMN
DATA: hr_weeknum TYPE REF TO cl_salv_wd_column_header.
CALL METHOD lr_weeknum->get_header
RECEIVING
value = hr_weeknum.
CALL METHOD lr_weeknum->set_resizable
EXPORTING
value = abap_false.
hr_weeknum->set_prop_ddic_binding_field(
property = if_salv_wd_c_ddic_binding=>bind_prop_text
value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
set the text of the column
CALL METHOD hr_weeknum->set_text
EXPORTING
value = 'C Form'.
Regards,
Srini. -
Convert different rows into single column
DB : 11.1.0.7
OS : Solaris Sparc 5.10
I have one query which is joining few tables and giving me output like below.
personnum orgnm
======= =======
6 Keyholder
9 Sales
3 Mgmt
I would like to convert that into single column like below.
col1
========
6,Keyholder,9,Sales,3,Mgmt
I have tried with pivot and decode, but not getting resule which I am exepcting. Any suggesstions ?yashwanth437 wrote:
listagg() function could work.LISTAGG is not available in 11.1. It was introduced in 11.2.
Anyway, XML solution:
with sample_table as (
select 6 personnum,'Keyholder' orgnm from dual union all
select 9,'Sales' from dual union all
select 3,'Mgmt' from dual
select rtrim(xmlagg(xmlelement(e,personnum || ',' || orgnm,',').extract('//text()')),',') col1
from sample_table
COL1
6,Keyholder,9,Sales,3,Mgmt
SQL> SY.
Maybe you are looking for
-
Error when scheduling backup job in OEM
We have Oracle 11.2 RAC on Redhat Linux. I was creating an customized backup job and get the errorsORA-01476: divisor is equal to zero ORA-06512: at "SYSMAN.MGMT_JOB_ENGINE", line 7544 ORA-06512: at "SYSMAN.MGMT_JOB_ENGINE", line 7699 ORA-06512: at "
-
DUPLICATE INVOICE VERIFICATION CHECKL
Hi How to set control for duplicating invoice verification. Like the same Delivery note or the Freight passing twice to be checked by an error message Please help Krishna
-
HT1937 how does the video work
How do i get my vidio to work on my imac computer
-
Hi, SAP is going to release TM 8.0 next year. Can anyone tell what are significant changes/ additions in TM 8.0 as compared to TM 7.0? Regards Shailesh
-
IOS8: Usage, storage - where is the music?
I am using iOS8 on an iPhone 5. I use iTunes Match and fill my music storage by just playing it into the cache. In iOS7 when I went to usage, I could see how much storage music is occupying. Swiping from right to left, I could also clear the music ca