To see values of same column in a single row
Hi,
I have a requirement. I've to show all the column values in a row (as a comma separated) through a single query (No custom functions can't be used). For example EMP table has these records (no fix no. of records).
empno ename
123 BILL
234 SCOTT
231 SIMOND
125 JAMES
now I have to show the values in a
BILL,SCOTT,SIMOND,JAMES manner.
Please help to find that. Thanks in advance.
---Sourav
Hi Yes its possible
With t As
Select 'A' col From dual Union All
Select 'B' From dual Union All
Select 'C' From dual Union All
Select 'D' From dual
Select replace(max(SYS_CONNECT_BY_PATH(col,' ')),' ') "Col"
From
Select col,
row_number() over (Order By col) As curr,
row_number() over (Order By col) -1 As prev
From t
Connect By prev = Prior curr
Start With curr = 1;
Col
ABCD
we have many threads which explains this issue the best one is i guess
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
Multiple rows into a single row.
Similar Messages
-
Concatenate strings from a column into a single row
I am trying to string values from a column into a single row. I need a list of students (one row per student) with their phone number and they could have more than one number. I found a function that should do what I need but the syntax is for SQL Server, not SQL*Plus. I've tried several variations but can not come up with the correct syntax.
This is the SQL Server version:
CREATE FUNCTION dbo.GetPhoneList(@StudentID int)
RETURNS varchar(500) AS
BEGIN
DECLARE @StringList varchar(500)
SELECT @StringList = COALESCE(@StringList + ‘, ‘, ”) + Telephone.PhoneNumber
FROM Telephone t
WHERE t.StudentID = @StudentID
IF @StringList IS NULL
SET @StringList = ‘No Phone’
RETURN @StringList
END
SQL*Plus does not like the @ symbol, so I tried taking that out. I've put semi-colons where I think they should be, but I still get various error messages. Any suggestions?
Thanks.Hi,
What you want to do is called "String Aggregation"
You could write a PL/SQL funcrtion to do that for a specific column in a specific table, but [this page|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] has a couple of different generic solutions that will work on any tables and columns.
I recommend the first soluton, the user-defined function STRAGG, which you can copy from that page.
Once you have STRAGG installed, your query can be something like:
SELECT s.student_id
, NVL ( STRAGG (t.phone_number)
, 'No phone'
) AS phone_nums
FROM student s
LEFT OUTER JOIN telephone t ON s.student_id = t.student_id
GROUP BY s.student_id;On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
WM_CONCAT is not documented, so you may not want to use it in your Production applications.
It lokks like
Edited by: Frank Kulash on Feb 10, 2009 6:31 PM -
How to aggregate a column based date column (for weekly single row)?
How to aggregate a column based date column (for weekly single row)?
Hi,
Consider the below statement for daily bases which is ok
SELECT ID, DATE, SUM(AMOUNT) FROM TABLE_NAME GROUP BY ID, DATE ORDER BY ID, DATE
The same like the above statement, I want output on weekly, fortnightly, and monthly bases, How to do this? Need your help... -
Multiple values from same column in diffetent columns in same row??
Hi all,
I am wondering how you can display different values from the same column into different columns on same row. For example using a CASE statement I can:
CASE WHEN CODE IN ('1', '3') THEN COUNT( ID) END as "Y"
CASE WHEN CODE NOT IN ('1', 'M') THEN COUNT( ID) END as "N"
Yes this will produce two columns needed but will also produce two separate records and null values for the empty's.
Any ideas?
ThanksIt's not clear what you want.
Can you post some examples as described in the FAQ: {message:id=9360002}
As my first guess, I would think you're looking for something like...
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> select count(case when deptno in (10,20) then deptno end) as deptno_10_20
2 ,count(case when deptno > 20 then deptno end) as deptno_30plus
3 from emp;
DEPTNO_10_20 DEPTNO_30PLUS
8 6 -
TableView - Filter more than one value in same column
Hi folks,
I faced a problem on <b>filtering a field more than one value</b>.
Does it possible solution for us to bring out filtering function while user try to enter few values in the SAME filter field?
Thank you.
First, i need to clarify my exact problem.
--> I have created one tableView with filter = "server". Then i want to allow my user to enter few filter values in same field column.
Example 1:
Before
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
CCC CCC CCC CCC
DDD DDD DDD DDD
EEE EEE EEE EEE
After
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
Is that any good suggestions to solve my doubt?
Message was edited by:
GP Pohcheck out this work around. in this sample currency column supports multiple values and multiple values in the filter column should be enter with comma as separater.
<u><b>page attribute:</b></u>
filtertab TYPE RSELOPTION
filter_wa TYPE RSDSSELOPT
itab TYPE FLIGHTTAB
<u><b>layout</b></u>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<htmlb:textView id ="tex"
text = "Filter on Currency Column support multiple values, they can be entered with comma as separater like 'usd,DEM'"/>
<htmlb:tableView id = "tv1"
design = "ALTERNATING"
table = "<%= itab %>"
filter = "APPLICATION"
columnHeaderVisible = "true"
sort = "SERVER" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
<u><b>oninitialization</b></u>
select * from sflight into table itab where currency in filtertab .
<u><b>oninputprocessing</b></u>
* event handler for checking and processing user input and
* for defining navigation
DATA: table TYPE REF TO cl_htmlb_tableview .
DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
DATA: filter_value TYPE string .
DATA: fil_val TYPE STANDARD TABLE OF string ,
fil_val_wa TYPE string .
REFRESH filtertab .
table ?= cl_htmlb_manager=>get_data( request = request
name = 'tableView'
id = 'tv1' ).
IF table IS NOT INITIAL .
tv_data = table->data .
IF NOT tv_data IS INITIAL .
CALL METHOD tv_data->get_row_filter_value
EXPORTING
column_index = 6
RECEIVING
value = filter_value.
IF NOT filter_value IS INITIAL .
TRANSLATE filter_value TO UPPER CASE .
REFRESH fil_val .
SPLIT filter_value AT ',' INTO TABLE fil_val .
CLEAR fil_val_wa .
LOOP AT fil_val INTO fil_val_wa .
filter_wa-sign = 'I' .
filter_wa-option = 'EQ' .
filter_wa-low = fil_val_wa .
APPEND filter_wa TO filtertab .
ENDLOOP .
ELSE .
REFRESH filtertab .
ENDIF .
ENDIF .
ENDIF .
Regards
Raja -
How to display integer values and decimal values in same column in a table
hi
in my report amount column is there in that column integer values (2234) and decimal values (3562.34)
i want to print this values as 1000 separate as like 2,234 as integer and 3,562.34 as decimal
but this values print like 2,234.00 as integer and 3,562.34 as decimalHi akilreddy,
Per my understanding you have an field which data type may be "float" in the DB, so it have value which format like "2234" and "3562.34" in the same column, now you want to format them differently in the report, right?
I have tested on my local environement and you can use the expression in the custom format in the Textbox properties to do this:
Right click the field which you want to add the format and select the "Text Box Properties"
Select the "Number" on the left pane and using expression below in the Custom format:
=IIF(Split(Fields!yourfieldname.Value,".").Length=2,"#,###.##",Nothing)
Or you can just use "#,###.##" in the format.
Preview you will go the result like below:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
Sum of values in same column of all tables
On the same sheet, I have multiple tables with the same column (F) titled "AMOUNT".
I want to get the sum of all the values in that column, from every table, without having to specify each table.
Is there a way to do this?It would be nice to not have to specify each table but it can't be done that way. Nonetheless, it is easy to get those sums. Type in =SUM( then click on the column letter (F in this case) of each of those tables until you have them all then add the closing parenthesis and hit return.
-
And condition for a value within same column
Hi,
I would like to select the rows from table which matches key='DKJ' and key='BK5'
Is it possible to use exists condition here...to get the result only when it contains both the keys. Please could you suggest me alternative query for the below..
SELECT a.or_no,b.key
FROM v_sp a,
v_off b
WHERE a.or_no = '27422739'
AND a.key_code = b.key_code
AND(b.mod = '00K'
AND(b.key = 'DKJ' OR b.keystroke = 'BK5'))
Many Thanks,
HariHi,
I would like to select the rows from table which
matches key='DKJ' and key='BK5'
Is it possible to use exists condition here...to get
the result only when it contains both the keys.
Please could you suggest me alternative query for the
below..
SELECT a.or_no,b.key
FROM v_sp a,
v_off b
a.or_no = '27422739'
AND a.key_code = b.key_code
AND(b.mod = '00K'
AND(b.key = 'DKJ' OR b.keystroke = 'BK5'))
What you say and what you do aren't the same. Please clarify. -
Display same value of a column once in multiple rows
Dear All:
I have a table id, values with following data
ID VALUES
===============
EG001 5888314
EG001 5888315
EG001 5888316
EG002 5888317
EG002 5888318
I want to display a query to display the result as follows:
ID VALUES
===============
EG001 5888314
5888315
5888316
EG002 5888317
5888318
Regards,
HassanHi,
Without subquery.
Regards Salim.
/* Formatted on 2009/06/05 09:49 (Formatter Plus v4.8.8) */
WITH test_tab AS
(SELECT 'EG001' rec_id, 5888314 VALUE
FROM DUAL
UNION ALL
SELECT 'EG001', 5888315
FROM DUAL
UNION ALL
SELECT 'EG001', 5888316
FROM DUAL
UNION ALL
SELECT 'EG002', 5888317
FROM DUAL
UNION ALL
SELECT 'EG002', 5888318
FROM DUAL)
-- end test data
SELECT CASE
WHEN MIN (VALUE) OVER (PARTITION BY rec_id) = VALUE
THEN rec_id
ELSE TO_CHAR (VALUE)
END rec_id,
CASE
WHEN MIN (VALUE) OVER (PARTITION BY rec_id) = VALUE
THEN VALUE
ELSE NULL
END VALUE
FROM test_tab;
REC_ID VALUE
EG001 5888314
5888315
5888316
EG002 5888317
5888318
5 rows selected. -
How to Sort one key figure values in two column based on single char
hi gurus,
I would really appreciate if some one can help me out with my question.
I have to design a query based on a Multiprovider built on three ODS, Purchasing, Confirmations & Invoic ODS
Purchase order Value and Number data in PO ODS, and confirmations is in CONFODS, Invoice Values in INV ODS,
The design of the requirement is
Vendor --> PO --> Material PO Value --> Text PO Value --> Confirmation value --> Invoice value
There are Two POS 1. Material PO & 2. Text PO
I need to display all the Purchase orders for a vendor and in different columns i need to display the value of the Material PO and Text PO and their Confirmation Value and how much is the invoiced value for every PO.
Can anybody tell me what should i do in the Query Designer to display the necessary values.
Thank youHi william,
When i put in the PO KF in the column and also the Confirmation KF in other Column it either shows me # for both the entries or it shows me values in only one of the column
if PO is displayed the Confirmation is not displayed and if Confirmation is displayed PO values are shown as # i dont know what wrong i am doing.
if you have idea can you tell me what i should do when i want two different values from two ODS if there are no characteristics that are matching in either of the ODS should i go for Multi Provider and if so how should be my designing. i would really appreciate if you can tell me taking a scenerio.
Thanks -
Trying to convert multiple rows into multipe columns within a single row
I am trying to convert data from multiple rows into multiple columns. Let me see if I can paint the picture for you.
Here is a sample of the table i am trying to read from:
Company Name Account
1 Sam 123
1 Sam 234
1 Joe 345
1 Sue 789
1 Sue 987
1 Sue 573
I am trying to put this into a View that would have the data represented as such:
Company Name Acct1 Acct2 Acct3 Acct4
1 Sam 123 234 <null> <null>
1 Joe 345 <null> <null> <null>
1 Sue 789 987 573 <null>
Many thanks in advance for your help!test@XE> --
test@XE> with t as (
2 select 1 as company, 'Sam' as name, 123 as account from dual union all
3 select 1, 'Sam', 234 from dual union all
4 select 1, 'Joe', 345 from dual union all
5 select 1, 'Sue', 789 from dual union all
6 select 1, 'Sue', 987 from dual union all
7 select 1, 'Sue', 573 from dual)
8 --
9 select company,
10 name,
11 max(case when rn = 1 then account else null end) as acct1,
12 max(case when rn = 2 then account else null end) as acct2,
13 max(case when rn = 3 then account else null end) as acct3,
14 max(case when rn = 4 then account else null end) as acct4
15 from (select company,
16 name,
17 account,
18 row_number() over (partition by company, name order by 1) as rn
19 from t)
20 group by company, name;
COMPANY NAM ACCT1 ACCT2 ACCT3 ACCT4
1 Joe 345
1 Sam 234 123
1 Sue 573 789 987
3 rows selected.
test@XE>
test@XE>isotope -
SSRS 2012
Dataset (40 columns) including the first 3 rows for Report layout configuration (eg: the <second> row specifies the column background color).
Starting from the 4th row, the dataset contains data to be displayed.
I would like to change the background color of the ColumnHeader/Column based on the value in the same column in the <second> row.
How can I accomplish the this requirement? (this must be applied for all the columns)
ThanksHi Fasttrck2,
Per my understanding that you want to specify the background color of all the columns/column header based on the value in one special column of the special row, right?
I have tested on my local environment and you can add expression to condition show the background color in the columns properties or the column header properties.
Details information below for your reference:
Specify the background color in the Column header: you can select the entire column header row and in the properties add expression in the Background color :
If you want to specify the background color for the entire column, you can select the entire column and add the expression, repeat to add background color for other columns.
If you want to specify the background color based on the value in the specific columns and row, you can create an hidden parameter to get the list of values from the specific column, specify the Available values and default values by select "Get
values from a query", finally using the expression as below to get the specific value you want:
Expression(Backgroud Color):
=IIF(Parameters!Para.Value(1)="1221","red","yellow")
If your problem still exists, please try to provide some smaple data of the report and also the snapshot of the report structure to help us more effective to provide an solution.
Any problem, please feel free to ask.
Regards
Vicky Liu
If you have any feedback on our support, please click
here.
Vicky Liu
TechNet Community Support -
Display multiple values in a column in ALV
I need to display plant order number from AFPO and PLAF table in reference to Goods Recepient(WEMPF) field.
now in final internal table I assign AFPO--> Plant number value to PLNUM column of ALV.
how do I add value to same column based on WEMPF common value for both table and append value to PLNUM column below value fetched from AFPO table.
code for getting value from PLAF table.
SELECT WEMPF PLNUM
FROM PLAF
INTO TABLE IST_PLAF
FOR ALL ENTRIES IN IST_AFPO
WHERE PLNNO = IST_AFPO-WEMPF
AND ......
Point is for some WEMPF field entried their will be number of entries in AFPO and PLAF table (in PLNUM column) so how I do displaying entries from both tables in single row??Hi Ankitkumar Dineshkumar Gautam,
SAP would say: "This is a consulting issue". I would say: What's your problem? Look at some samle programs.
Regards,
Clemens -
How to select only first few values in a Column
Hi, in one of the column of type SDO_GEOMETRY. In that column we have many values. Example : *(-6.33787700000002, 56.547309, -6.33786800000001, 56.547279, -6.33781400000001, 56.547249, -6.33776900000001)*
I wanted to know how can i select only first two or last two values from within the column.
Eg: i want only -6.33787700000002, 56.547309 to be displayed
ThanksHi,
Are the value specified here are multirow or single row data?
if it is multi row, Karthick solution should work. Else if it is a single row then try this
with T as
select '-6.33787700000002, 56.547309, -6.33786800000001, 56.547279, -6.33781400000001, 56.547249, -6.33776900000001' SDO_GEOMETRY from dual
-- end of sample data
select substr(SDO_GEOMETRY,1,instr(SDO_GEOMETRY,',',1,&cnt)-1) Output from T
PRAZY@11gR2> /
Enter value for cnt: 2
OUTPUT
-6.33787700000002, 56.547309
Elapsed: 00:00:00.05And remember, while posting questions it is good to specify your DB version with clear sample data and required output.
HTH,
Prazy -
Interactive report: Can I exclude a particular column from single row view?
Hi -- I posted on this yesterday (Possible to exclude interactive report column from single row display?
a bit anxious for suggestions, I guess!
I've added a column with edit-link functionality to my interactive report query (that is, the link
is not attached to the database data... it's an additional column and shows an icon). It's also
in addition to the default single row view link. (We need both.)
Unfortunately, the Edit link column shows up in the single row view. I've pared it down as much
as I can: the label is empty, and the null value shows as "-". But an extra row with "-" is pretty
ugly. Is there a way to always, completely exclude this column from the single row view?
I know I could put the edit link on a data column, but:
1) I want the link to always be to the left of the data (and the user can re-order columns)
2) when the user doesn't have edit privileges, the link will need to be disabled or just not
be displayed, and I think that would be a problem if the link were on the data. (true?)
Thanks,
CarolPlease disregard this thread, and the one it refers back to. I see a flaw in the design of what I was attempting to do! Creating the link for Editing as a column means the user could inadvertently not display it, or move it, or... any number of problematic scenarios.
Thanks,
Carol
Maybe you are looking for
-
I am a Nokia user from India. I have Nokia N70. I have no vouchers or unlimited subscription. I do not want to change my phone as it work really well. There is some Pay Credit feature which I can't see how to activate. Does that mean I can't use Noki
-
Execute Task works in one area but not the other
I have two Execute SQL Tasks. Each executes the same stored procedure from the SQL Statement property with a different parameter and they insert into the same table. One is at the end of the package and only runs if a Rollback is done and it works
-
I am an Sap hr consultant and i am looking to expand my skills and become ish consultant. Can anyone please let me know how to go about it...
-
RTL and Hebrew support for numbers and pages? when will we have the option for that?
Still, after 4 years of IOS, there isnt even one sodtware that supports RTL and Hebrew\Arabic, is there a chance that in the near near future we will see that support in "Numbers" and in "Pages"? Thanks...
-
I have a problem with automatic uploading of file in Acrobat 8.1. I'm trying to avoid security restrictions using document sertifying. I set option "Execute high priveledge JavaScripts that are embedded in a certified document", but it didn't affect.