Out of proc - values from multiple rows.
I have 5 tables. Every table has the following columnsTRANS_ID,
USER_ID,
OPRTN_TYPE,
STATUS,
DATE
I have to write a proc for which an entry is USER_ID and output must be TRANS_ID, OPRTN_TYPE, STATUS, DATE.
Is it possible to write the proc with the mentioned columns, the values will be more than one row in the table.
user13024762 wrote:
I have 5 tables. And I need output of all tables at the same time. If I want to use Ref Cursor I write a cursor for each query with 5 outputs, or I can do it with a single output.
No, just return a single Ref Cursor
Is it possible to bring together the tables? As I don't have your database or model, it is difficult to advise you on this.
You could do something like
select TRANS_ID,
USER_ID,
OPRTN_TYPE,
STATUS,
DATE
from table1
where user_id = p_parameter
union all
select TRANS_ID,
USER_ID,
OPRTN_TYPE,
STATUS,
DATE
from table2
where user_id = p_parameter
and this return as a Ref Cursor
Thanks for the link refcursor.
You are welcome.. ;)
Tags: Database
Similar Questions
-
To access the values from the row outside the ListView ListItem
Hello
I spent two hours browsing the forums and documentation with no chance of finding a solution on how to access the list item data from outside the listview.
Let explain me my code. It is marked with I work and what does not work and its expected behavior.
Should work behavior
Tapping & getting dataThe arrayDataModel is filled with 4 rows. Firstly the list item, second item in the list... etc.
- Tapping on the order of the day, label with the id of triggeredText displays the value of a threaded list item.
- The index of the tapped icon appears in the label with the id of triggerredIndex.
Incrementing Index using ActionItems onBar
By pressing action items 'previous' and 'next', you can increment the index value to the label with the id of triggeredIndex. The order of the index is 0-4, even as total of the items in the list.
How to extract data from the index when the value of triggeredIndex?
Buttons
The buttons at the bottom of the screen... Select 1, select the 2nd, 3rd Select should select indexes 0,1,2 of the list and display the value in triggeredText and triggeredIndex. They do not work.
How did I pull the values when you click the buttons?
import bb.cascades 1.3 TabbedPane { id: root showTabsOnActionBar: false Tab { id: mainTab title: "Test List" Page { id: mainPage titleBar: TitleBar { title: "List Traversal Test" } actions: [ ActionItem { title: "Previous" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // get current selected index from list= var currentIndex = parseInt(triggeredIndex.text); if(currentIndex <= 0){ //do nothing already at first item }else{ // subtract 1 from index ( ci - 1) ? var newIndex = parseInt(triggeredIndex.text) - 1; // show data from new selected index // ??? // triggeredItem.text = XXX // the data // ??? // triggeredIndex.text = X // the current index triggeredIndex.text = newIndex; } } }, ActionItem { title: "Next" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // get current selected index from list= var currentIndex = parseInt(triggeredIndex.text); if(currentIndex == 4){ //do nothing already at lastitem }else{ // add 1 to index ( ci + 1) ? var newIndex = parseInt(triggeredIndex.text) + 1 // show data from new selected index // ??? // triggeredItem.text = XXX // the data // ??? // triggeredIndex.text = X // the current index triggeredIndex.text = newIndex; } } }, ActionItem { title: "Clear" ActionBar.placement: ActionBarPlacement.OnBar onTriggered: { // set current index to 0 (top item in list) } } ] Container { preferredHeight: maxHeight layout: StackLayout { orientation: LayoutOrientation.TopToBottom } Label{ id: triggeredItem // value of listitem from current index text: "0" } Label{ id: triggeredIndex // current index text: "0" onTextChanged: { // set triggeredItem.text to contents of selected ListItem with same index // STUCK HERE cannot access ListItem.dataModel(indexPath) from here.... } } Container{ ListView { id: theList objectName: "dalist" dataModel: ArrayDataModel { id: theListModel } listItemComponents: ListItemComponent { StandardListItem { id: itemRoot title: ListItemData } } onTriggered: { var si = dataModel.data(indexPath); triggeredItem.text = "LIST ITEM CONTENT: " + si; //set content when user taps on item triggeredIndex.text = "LIST ITEM INDEX INDEX: " + indexPath; // set index when user taps } onSelectionChanged: { //console.log(selected); } onCreationCompleted: { //add some data to the listview theListModel.append("First List Item"); theListModel.append("Second List Item"); theListModel.append("Third List Item"); theListModel.append("Fourth List Item"); } } } Container{ layout: StackLayout { orientation: LayoutOrientation.LeftToRight } Button{ text: "Select 1st" onClicked: { theList.clearSelection(); theList.select(0); } } Button{ text: "Select 2nd" onClicked: { theList.clearSelection(); theList.select(1); } } Button{ text: "Select 3rd item" onClicked: { //expected behaviour is to show data from Third List Item // triggeredIndex.text = INDEX 3 // triggeredText.text = (DATA FROM THIRD LIST ITEM) // THIS IS NOT WORKING .... theList.clearSelection(); theList.select(2); console.log(theList.dataModel(3)); triggeredItem.text = theListModel.dataModel(3); } } } } } }//tab }
Thank you and have a happy and healthy 2015!
Your help will be greatly appreciated.
I ran and got this:
asset:///main.qml:161: TypeError: Result of expression 'theList.dataModel' [bb::cascades::ArrayDataModel(0x1091a838)] is not a function.
But it works
theListModel.data([3])
But this isn't the solution, you have a more serious problem. You select a value, you trigger. If you add this in onTriggered you select it (and you can see that it changes color when it is selected).
theList.select(indexPath);
If you want to use option to deselect
theList.select(indexPath, !theList.isSelected(indexPath));
And if you want to have that one chose this
theList.clearSelection(); theList.select(indexPath);
Inside the button 'Select the 3rd point' allows to select programmatically
theList.select([2]);
It works but I'm not sure what you're trying to do
-
Get a value from a row in a column
I have a table contains the following data
ID Student class classeRoom 1 English 3-B 3-B 2 null null 3-B 3 null null 3-B 4 Jack OuMe 3-B 5 Richard DSA 3-B 6 Jhon Ross 3-B 7 French 3-B 3-B 8 null null 3-B 9 null null 3-B 10 Jack OuMe 3-B 11 Richard DSA 3-B 12 Jhon Ross 3-B 13 Spanish 5-B 5-B 14 null null 5-B 15 null null 5-B 16 Cena ADI 5-B 17 Mike Rock 5-B 18 Philippe DSK 5-B I need a select query to get the result as below:
ID Student class classeRoom CLASSES 1 English 3-B 3-B English 2 null null 3-B English 3 null null 3-B English 4 Jack OuMe 3-B English 5 Richard DSA 3-B English 6 Jhon Ross 3-B English 7 French 3-B 3-B French 8 null null 3-B French 9 null null 3-B French 10 Jack OuMe 3-B French 11 Richard DSA 3-B French 12 Jhon Ross 3-B French 13 Spanish 5-B 5-B Spanish 14 null null 5-B Spanish 15 null null 5-B Spanish 16 Cena ADI 5-B Spanish 17 Mike Rock 5-B Spanish 18 Philippe DSK 5-B Spanish I tried something like this:
Select ID, STUDENT, CLASS, FIRST_VALUE (STUDENT) IGNORE NULLS above (SCORE FROM CLASSEROOM ORDER BY ID) CLASSES from my_table
but I don't have the answer
Thanks for help
How about this slight adjustment to the solution of Solomon?
select id, student, class, classeroom, last_value( case when class = classeRoom then student end ) ignore nulls over(order by id) classes from t order by id;
ID STUDENT CLASS CLASSEROOM CLASSES 1 English 3-B 3-B English 2 null null 3-B English 3 null null 3-B English 4 Jack OuMe 3-B English 5 Richard DSA 3-B English 6 Jhon Ross 3-B English 7 French 3-B 3-B French 8 null null 3-B French 9 null null 3-B French 10 Jack OuMe 3-B French 11 Richard DSA 3-B French 12 Jhon Ross 3-B French 13 Spanish 5-B 5-B Spanish 14 null null 5-B Spanish 15 null null 5-B Spanish 16 Cena ADI 5-B Spanish 17 Mike Rock 5-B Spanish 18 Philippe DSK 5-B Spanish -
Data from multiple rows in single line in BI publisher 11g
Hello
I receive documents in multiple lines
for example
ID case1, case3 CAS2
1 C1
1 C1
1 C2
1 C4
Now, I want to make it as a single line, output desired is
ID Case1, Case3 CAS2
1 C1 C2 C4
is it possible, please let me know.
Thanks in advance
Kind regards
Sam
He seems to do at the level of the model.
Could you please post your example of xml data?
-
How to read a value from a cell in a row
Hello;
I need the name of a function that is able to read a value from a cell in a row. the line contains multiple values.
If you can post for me, I grow
-
To create an interactive report in the apex by selecting from multiple tables
Hi, I am creating an interactive report by selecting from multiple tables.
SELECT w.FIRST_NAME as name, w.SURNAME as name, i.ROAD Road, i.DATE_OF_INC as DATE_OF_INC, S.STATEMENT as a STATEMENT OF Declaration
JOIN THE
WITNESS w
ON w.witness_id = s.FK1_WITNESS_ID
JOIN THE
Incident I have
WE
i.incident_no = w.FK1_INCIDENT_NO
JOIN THE
user_station ps
ON ps.station_id = i.nearest_station_id
JOIN THE
the user in.
WE
in. STATION_ID = ps.station_id
WHERE po.officer_id = 1
by I continue to encounter this error "the report query requires a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column. "ORA-01445: cannot select ROWID from where sample, a join without key preserved table view '
So I googled around and found that in the attibutres tables report, I need to change the "LINK" COLUMN so first, I changed "Link to custom target", but the report is so I changed it to "Exclude link Clolumn" again, the report didn't report and I STILL got a blank page with only the tabs.
I wonder you can not create a report by selecting from multiple tables?
If you can please I need your help.
Thank you
You can, but in this case, it might be easier to build your report tables that are joined Oracle views and then build your report out of the newly built sight...
Or wrap a selection around your selection with joins, and then make the where clause on the external selection...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
concurrent writes to a logfile from multiple threads (Java 7)?
Hello everyone
I have a multi-threaded Java 7 (jar file) program that uses JDBC to perform work (he uses a fixed pool of threads).
The program works very well and it records things that it moves the console command shell window (System.out.printf ()) starting from multiple concurrent threads.
In addition to the release of the console, I also need to add the capability of this program write in a single flat ASCII text file journal - starting from multiple threads.
The output volume is low, the file will be relatively low because it is not a data file, a log file.
Can you please suggest a relatively simple and good to achieve design/approach using Java 7 features (I have not yet Java 8)?
The code examples would also be appreciated.
Thank you very much
I have a multi-threaded Java 7 (jar file) program that uses JDBC to perform work (he uses a fixed pool of threads).
The program works very well and it records things that it moves the console command shell window (System.out.printf ()) starting from multiple concurrent threads.
In addition to the release of the console, I also need to add the capability of this program write in a single flat ASCII text file journal - starting from multiple threads.
The output volume is low, the file will be relatively low because it is not a data file, a log file.
Can you please suggest a relatively simple and good to achieve design/approach using Java 7 features (I have not yet Java 8)?
The code examples would also be appreciated.
Use a dedicated thread for logging and a queue to source it. See the "queue implementations of the trails in the Java tutorials for the use of queues and the code example that works.
https://docs.Oracle.com/javase/tutorial/collections/implementations/queue.html
Java has several classes of queue synchronized you can use if those in this tutorial are not suitable for your use case. Here's just one:
https://docs.Oracle.com/javase/7/docs/API/Java/util/concurrent/ConcurrentLinkedQueue.html
Unlimited thread-safe queue based on linked nodes. This queue orders elements FIFO (first-in-first-out). The head of the queue is this element which remained the longest the queue. The tail of the queue is this element that has been on the queue as quickly as possible. New elements are inserted at the tail of the queue, and get the recovery operations of the queue of the elements at the head of the queue. At
ConcurrentLinkedQueue
is a good choice when the number of threads will share access to a common collection. Like most other concurrent collection implementations, this class does not allow the use ofnull
elements.Using a queue your current code can add recording which is FAST because it is add an instance of the class to a collection rather interact with the file system. And your current code requires NO knowledge of the functioning of the system of newspaper, that it connects or when and where it connects.
For your use case use you a synchronized queue and edit each of your worker threads to add their log data to the master queue used by the newspaper for the logging thread.
You shouldn't have multiple threads trying to write directly in the same file.
The entire point of the modular and multi-processing programming is to BREAK dependencies between modules of code.
The logging system must be INDEPENDENT of the other code and your current code must NOT have ANY need or knowledge of the file system or OF the specificity of the way where, or when the data is actually stored.
Your code must run simple and minimal logging by adding its data to a queud. Once the log data was added to the queue and then, as far as your code is concerned, that data has been noted. It should be ONLY module log to determine the LOCATION to save the data, HOW to record data and even WHAT information to log.
You can add the larger newspapers in the future: newspapers, paper 1) different levels of 2) to a remote server or the database 3 send some events in the log.
I suggest you create a SIMPLE D.O. (data object) to maintain the log info (attributes like gravity, time/date, type of exception stack, error, etc.). Then create a class of SIMPLE log with several overloaded methods: a method that takes a single parameter, with two, etc. Javas is owner of exception classes have some simple examples of both simple and complex, nested exception handling.
These methods journal would take care to fill in the NEWSPAPER to DO correctly and then placing the instance of the D.O. to the journal queue. In this way, you can use a parameter of a simple newspaper just pass an error message and the log class method will add a default severity level (which can vary from thread if you want), time (which can range from wire) and other necessary data.
The goal is to keep the journal interface use you in your existing code as SIMPLE as possible while keeping as independent as possible of the actual logging mechanism.
The result is a mechanism of simple logging that is versatile and scalable and can then be used for your PROJECTS that require a registration (file, database, e-mail).
Do not make the mistake to hardcode the mechinism journal in your existing code.
DO not continue independent, modular architecture that you already use.
-
Can someone help me create a procedure with the DML statements that insert values from 1 to 100 in a table "abc" and the procedure must connect the numbers into words in another table "xyz" without doing a commit explicitly. "."
Currently on trial...
SQL > create table abc (num number);
Table created.
SQL > create table xyz (num varchar2 (100));
Table created.
SQL > ed
A written file afiedt.buf1. insert all
2 values of 1 = 1 then in abc (num) (l)
3 when the values of 1 = 1 then in xyz (num) (to_char (to_date(l,'j'), 'jsp'))
4 * Select the level from dual connect by level<=>=>
SQL > /.200 rows created.
And the result...
SQL > select * from abc;
NUM
----------
1
2
3
4
5
6
7
8
9
10
11
12
..
..
..
98
99
100100 selected lines.
SQL > select * from xyz;
NUM
----------------------------------------------------------------------------------------------------
one
two
three
four
five
six
seven
eight
nine
ten
Eleven
twelve
..
..
..
98
Nineteen eighty
Cent100 selected lines.
-
Insert the value from the date of the operation, max
Hello
We use oracle 10g R2 on windows.
I want to insert values from one table to the other. Suppose I have a table emp (empcode, salary, dt_update) and have another table emp_live (empcode, salary).
data into the emp table are as
My requirement is to insert only those records where the maximum date of DT_UPDATE.EMPCODE SALARY DT_UPDATE 281G 10611230.319 10/9/2010 6:38:30 PM 281G 37819399.457 10/8/2010 6:38:30 PM 291G 16500012.429 10/10/2010 6:38:30 PM 291G 108145595.738 10/9/2010 6:38:30 PM 292G 79449005.406 10/11/2010 6:38:30 PM 292G 198819948.865 10/10/2010 6:38:30 PM 293E 4532332.618 10/12/2010 6:38:30 PM 293E 142572824.216 10/11/2010 6:38:30 PM 294D 116505728.748 10/13/2010 6:38:30 PM 294D 90087585.925 10/12/2010 6:38:30 PM
In the above senario only records below need to obtain insert
I am trying to insert it asEMPCODE SALARY DT_UPDATE 281G 10611230.319 10/9/2010 6:38:30 PM 291G 16500012.429 10/10/2010 6:38:30 PM 292G 79449005.406 10/11/2010 6:38:30 PM 293E 4532332.618 10/12/2010 6:38:30 PM 294D 116505728.748 10/13/2010 6:38:30 PM
But above not giving not correct results beacase when I select the records asinsert into emp_live select empcode,salary from emp where dt_update=(select max(dt_update) from emp)
Above shows 1665 records, but when I am inserting only insert 16 records.select empcode,max(dt_update) from emp group by empcode
Help, please.Something like this:
create table test (empcode varchar2 (4), salary number, date of dt_update);
Insert test values (' ' 281 G ", 10611230.319, to_date (October 9, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values (' ' 281 G ", 37819399.457, to_date (October 8, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values (' ' 291 G ", 16500012.429, to_date (October 10, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values (' ' 291 G ", 108145595.738, to_date (October 9, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values (' ' 292 G ", 79449005.406, to_date (October 11, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values (' ' 292 G ", 198819948.865, to_date (October 10, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
insert into test values ('293E', 4532332.618, to_date (October 12, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
insert into test values ('293E', 142572824.216, to_date (October 11, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values ('294, 116505728.748, to_date (October 13, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))
Insert test values ('294, 90087585.925, to_date (October 12, 2010 06:38:30 ',' mm/dd/yyyy HH24:MI:SS));))SQL> column salary for 99999999999.9999; SQL> select * from test; EMPC SALARY DT_UPDATE ---- ----------------- --------- 281G 10611230.3190 09-OCT-10 281G 37819399.4570 08-OCT-10 291G 16500012.4290 10-OCT-10 291G 108145595.7380 09-OCT-10 292G 79449005.4060 11-OCT-10 292G 198819948.8650 10-OCT-10 293E 4532332.6180 12-OCT-10 293E 142572824.2160 11-OCT-10 294D 116505728.7480 13-OCT-10 294D 90087585.9250 12-OCT-10 10 rows selected.
SQL> ed Wrote file afiedt.buf 1 select min(empcode),max(salary),max(dt_update) 2 from test 3 group by empcode 4* order by 1 SQL> / MIN( MAX(SALARY) MAX(DT_UP ---- ----------- --------- 281G 37819399.5 09-OCT-10 291G 108145596 10-OCT-10 292G 198819949 11-OCT-10 293E 142572824 12-OCT-10 294D 116505729 13-OCT-10
SQL> insert into test 2 ( 3 select min(empcode) empcode,max(salary) salary,max(dt_update) dt_update 4 from test 5 group by empcode 6 ) 7 / 5 rows created. SQL> select * from test; EMPC SALARY DT_UPDATE ---- ----------------- --------- 281G 10611230.3190 09-OCT-10 281G 37819399.4570 08-OCT-10 291G 16500012.4290 10-OCT-10 291G 108145595.7380 09-OCT-10 292G 79449005.4060 11-OCT-10 292G 198819948.8650 10-OCT-10 293E 4532332.6180 12-OCT-10 293E 142572824.2160 11-OCT-10 294D 116505728.7480 13-OCT-10 294D 90087585.9250 12-OCT-10 281G 37819399.4570 09-OCT-10 EMPC SALARY DT_UPDATE ---- ----------------- --------- 293E 142572824.2160 12-OCT-10 294D 116505728.7480 13-OCT-10 291G 108145595.7380 10-OCT-10 292G 198819948.8650 11-OCT-10 15 rows selected. SQL>
Concerning
Girish Sharma -
single line sub query returns multiple rows
Hi, please help me to solve this, working with oracle 11g.
Update t1 set t1.twyindex = twypoly (select twyindex from twyinfo where t1.id = t2.id t2);
the error message is:
*
ERROR on line 1:
ORA-01427: einreihig subquery returns multiple rows
Thank youdon123 wrote:
Hi paul, thanks...duplicate existing due to the business logic data.
can I use the SQL mentioned above for all cases?
is it mandatory to remove duplicates?
Please provide your suggestions...
If the company says duplicates are allowed, you have to ask the person who wants what, of the different twyindexes, that they want to use
updating twyinfo table...I use the SQL proposed until they tell you that twyindex to use.
-
Add the value of table row selected PageFlowScope so that I can access taskflow
Hi all
Facing a problem of getting a value from a table ADF selected line to a taskflow that appears as an inline popup. Here's the scenario. I have a vision that shows a table. When I click on an edit btn I display my taskflow as an inline popup. What I would do, is to take the line of the selected table, remove lets say the value of line name and pass it on to my taskflow for display. I tried this value within an mbean settting when I click the btn edit using:
That seems to get together, but when I try to enter this value using EL inside my page of jspx taskflow it seems to be not defined.AdfFacesContext.getCurrentInstance().getPageFlowScope().put("editTargetNameSource", targetName); String tmpClear = (String) AdfFacesContext.getCurrentInstance().getPageFlowScope().get("editTargetNameSource");
It seems that pageFlowScope for my taskflow popup! = pageFlowScope for page my table saw to. I tried to put this as a parameter of the entry page, but I have the feeling that I missed something. I wish I could set this value within my bean when a user clicks the edit btn and then display that value in my taskflow popup.<af:outputLabel value="Selected Row" id="ol1"/><af:outputText value="#{pageFlowScope.editTargetNameSource}"
Any help is appreciated,
-WraithRequestContext requestContext = RequestContext.getCurrentInstance ();
requestContext.getPageFlowScope () .put ("editTargetNameSource", targetName); -
SQL Help: convert values in two rows in a line
Hello
I am using Oracle 11.2, I want to get the values in different rows in the Tb_a table and insert them into the TB_b table as suite:
create a Tb_a (number (5) id, init_dt date, upd_dt date, addr varchar2 (32));
create a Tb_b (number (5) id, date upd_dt, addr varchar2 (32), dated hist_dt);
insert into Tb_a values (101, to_date('ddmmyyyy','21/08/1990'), to_date('ddmmyyyy','22/08/1990'), "address1");
insert into Tb_a values (101, to_date ('ddmmyyyy', 21 August 1991 '), to_date ('ddmmyyyy', 22 August 1991 '), "address2");
insert into Tb_a values (101, to_date('ddmmyyyy','21/08/1992'), to_date('ddmmyyyy','22/08/1992'), "address3");
insert into Tb_a values (102, to_date('ddmmyyyy','24/08/1990'), to_date('ddmmyyyy','25/08/1990'), 'address_address');
I would like to have data in TB_b as follows.
101, 22 August 1990 ","address1", August 21, 1991"
101, August 22, 1991 ","address2", August 21, 1992 '"
101, August 22, 1992 ', 'address3', null
102, 25 August 1990 ', 'address_address', null
Suggest on the SQL to perform the conversion of Tb_a to Tb_b?
Thank you939569 wrote:
I wish that each line of TB_b has the same value to the ID of the column, upd_dt and addr as Tb_a and the next value in the crt_dt of the Tb_a column.Or table has a column called crt_dt. Do you mean init_dt?
This rule applies to the same ID only. How can I use LEAD on different ID, not the whole picture?
Inlcude
PARTITION BY id
in the analytical clause, like this:
INSERT INTO tb_b ( id , upd_dt , addr , hist_dt ) SELECT id , init_dt , addr , LEAD (init_dt) OVER ( PARTITION BY id ORDER BY init_dt ) FROM tb_a;
-
How to get 3table of values in the row of acronym in 11g
Hi all
I have 3 tables,
In all ck_no tables is common.Tab1 Ck_no amt 1 2000 Tab2 Ck_no Line amt 1 1 1000 1 2 1000 Tab3 Ck_no Line sub amt 1 1 1 500 1 1 2 500 1 2 1 100 1 2 2 200 1 2 3 700
Since the 3 tables above, I need the output in the following format,
Can someone help me in this?Amt1 amt2 amt3 amt4 amt5 amt6 amt7 amt8 amt 9 2000 1000 1000 500 500 500 100 200 700
Thank you
Kind regards
Gurujothi
Published by: Gurujothi on July 9, 2012 20:46
Published by: Gurujothi on July 9, 2012 20:47Gurujothi wrote:
I know how to get the values in a row for a single column,
...
but I get the error,Too Many values
How do I change this?
Please post your data in the example, the expected results of these data and explain the logic so that we can understand how the data relate to each other.
In your original post, it is not clear how amt4, amt5 abd amt6 therefore show them all 500 when there are only two 500 values in the source data.
SQL> ed Wrote file afiedt.buf 1 with Tab1 as (select 1 as ck_no, 2000 as amt from dual) 2 ,Tab2 as (select 1 as ck_no, 1 as line, 1000 as amt from dual union all 3 select 1, 2, 1000 from dual) 4 ,Tab3 as (select 1 as ck_no, 1 as line, 1 as sub, 500 as amt from dual union all 5 select 1, 1, 2, 500 from dual union all 6 select 1, 2, 1, 100 from dual union all 7 select 1, 2, 2, 200 from dual union all 8 select 1, 2, 3, 700 from dual) 9 -- 10 -- END OF TEST DATA 11 -- 12 select ck_no 13 ,max(decode(rn,1,amt)) as amt1 14 ,max(decode(rn,2,amt)) as amt2 15 ,max(decode(rn,3,amt)) as amt3 16 ,max(decode(rn,4,amt)) as amt4 17 ,max(decode(rn,5,amt)) as amt5 18 ,max(decode(rn,6,amt)) as amt6 19 ,max(decode(rn,7,amt)) as amt7 20 ,max(decode(rn,8,amt)) as amt8 21 ,max(decode(rn,9,amt)) as amt9 22 from ( 23 select ck_no, amt, row_number() over (partition by ck_no order by ord, line, sub) as rn 24 from ( 25 select 0 as ord, ck_no, 0 as line, 0 as sub, amt from tab1 union all 26 select 1 as ord, ck_no, line, 0 as sub, amt from tab2 union all 27 select 2 as ord, ck_no, line, sub, amt from tab3 28 ) 29 ) 30* group by ck_no SQL> / CK_NO AMT1 AMT2 AMT3 AMT4 AMT5 AMT6 AMT7 AMT8 AMT9 ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 1 2000 1000 1000 500 500 100 200 700
-
first value in multiple columns
Published by: 846773 on 11 January 2012 10:20Hi experts, select * from ( select 1 col1,3 col2,5 col3 from dual union all select 6 col1,5 col2,5 col3 from dual union all select 2 col1,3 col2,5 col3 from dual union all select 10 col1,3 col2,5 col3 from dual union all select 11 col1,3 col2,5 col3 from dual ) I have to get the first value from the each rows: first_value ----------- 1 6 2 10 11 Thanks in advance
Or maybe he wants to say:
select coalesce(col1,col2,col3) first_value from ( select 1 col1,3 col2,5 col3 from dual union all select 6 col1,5 col2,5 col3 from dual union all select 2 col1,3 col2,5 col3 from dual union all select 10 col1,3 col2,5 col3 from dual union all select 11 col1,3 col2,5 col3 from dual )
accounting for null values.
Published by: BluShadow on January 11, 2012 15:44
stupid citrix browser didn't paste correctly -
How to get the values of the rows in a column only?
How to get all the values in the rows of a column.
for example, a query gives result as:
123
234
233
12121
all in different lines. But I want the result like this:
123,234,233, 12121.All in a single row and a single column.
How is that possible?SELECT rtrim (xmlagg (xmlelement (e, column_name |))) (') .extract('//text () '), ',') from table_name
Maybe you are looking for
-
The vi in the file (mt_nifgen_am_ssb_signal_gen.vi) can be used to generate an acoustic one AM SSB signal through a 5401 pxi and labview 2012 student? If not, can someone recommend another example vi the vi above would be reduced 80% development time
-
Help to "problem"-WRT54G, Linux, Unix and Windows ".
I have a Linksys WRT54G rev 6, firmware version v8.00.7 011, July 27, 2009. My ADSL modem is a modem DSL from Westell G90-610014-20 revD. My home network is 'predominantly' Windows wireless clients and a wireless printer, who don't have no problems
-
original title: Security Center I had a virus to infect my computer but I'm to remove by doing the scans. I can't solve the problem of after-sales service. "" My Windows J.4 Center repair center is currently disabled but when I try to turn it on I ge
-
ADC Server has stopped working
I get this. What that means, that means ADC server. Doesn't seem to affect my computer, even if the impression is a pain. I connect to a vpn to access my email and company information. But it seems coming wether I'm on VPN or not. Thank you
-
Everyone using SSD storage for files of Redologs
I intend to create redologs on storage ssd, our version of the database 11g so please advise me. It will improve performance or not?