How to break one row records into 3 row records
I have two tables which consists of date records,
table1
first_date second_date
01-feb-10 01-mar-10
tabl2
new_date old_date
01-jan-10 01-aug-10
if first table dates falls between new_date and old_dates, i need to showit as three row records instead of1 row in table2
Hi,
1001383 wrote:
I have two tables which consists of date records,
table1
first_date second_date
01-feb-10 01-mar-10
tabl2
new_date old_date
01-jan-10 01-aug-10
if first table dates falls between new_date and old_dates, i need to showit as three row records instead of1 row in table2Do both first_date and second_date have to fall between old_date and new_date, or is it enough if either one does?
What do you want to see on those 3 rows?
Depending on your data and your requirements, here's one way:
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 3
SELECT t2.*
FROM table2 t2
CROSS JOIN cntr
WHERE EXISTS (
' SELECT 1
FROM table1 t1
WHERE t1.first_date BETWEEN t2.old_date AND t2.new_date
OR t1.second_date BETWEEN t2.old_date AND t2.new_date
;I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements) for both tables, and the results you want from that data.
Include examples of any special situations you need to handle, such as the same row in table2 matching several rows in table1.
See the forum FAQ {message:id=9360002}
Similar Messages
-
How to use one report column into the another report in obiee
How to use one report column into the another report in obiee
i dont want to use column as a filter for another report it should be report column for another report
Thanks,
Vivek -
How to update one row in AdvancedDataGrid
My App have a AdvancedDataGrid and it has so much rows. Some
data rows for AdvancedDataGrid has changed and i don't want to
update all rows ... But i don't know how to update one row for my
AdvancedDataGrid
Some body help me ...
Thanks so muchs !thanks ntsii.
my problem is:
[Bindable]
var dp:ArrayColection = new ArrayColection({...});
<mx:AdvancedDataGrid dataProvider="{dp}">
<mx:groupedColumns>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
//==================================
in my dp have more rows and some time one of them is changed
then i guess the AdvancedDataGrid must build all rows when
it's dataProvider (dp) have changed.
And i don't want to that...
But i am not sure the AdvancedDataGrid buld all rows from
begin to end ... i don't know.. ! -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
How to break the PDF file into images?
How to break the PDF file into images? There should be settings in Photoshop CS 6 that imports PDF file and break it into images. I have a short instruction:
2. Open the file in Photoshop.
3. A new window should open to Import PDF. Click on images, not pages import pdf into Photoshop.doc
4. Select all the files shown (shift + click), Click O.K. Four files should open on your screen.
Was anybody successful with that?Whether this is available solely depends on the structure of the PDF and whether it actually contains whole images that can be extracted separately. Depending on whatgoing on in the PDF this may simply not be the case and the images have been tiled and split up in multiple "objects" whose appearance can only be retained by rasrerizing the whole page...
Mylenium -
How to retrive one table records into another table by multiple records
how to retrive table X records into another table Y by multiple records (means at once i want display 10 records) in form 6i .
when i am written cursor it is ftching only one record.But i want to display all records at once.
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae WHERE PROTOCOL_NO='KP229';
Begin
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Hi,
Make sure the cursor is in the detailed block. For that use 8GO_BLOCK* built-in. So the code will be
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae;
Begin
GO_BLOCK('<detailed_block_name>');
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Regards,
Manu.
If my response or the response of another was helpful or Correct, please mark it accordingly -
How to break the name column into first,middle,last
hi,
Having a column in a table called employee_name which is
containing the names of employees like:-
employee_name
Syed Azhar Husain
Also having another table having cloumns first_name,middle_name, last_name
I just want to write the query that break my employee_name column into
first name, middle name, last name and
store into table columns first_name, middle_name, last_name respectively
i.e. it should display like
first_name middle_name last_name
Syed Azhar husain
I am using oracle9i database.
Thanks in advance
AzharDear Asuri,
Thanks for quick reply,
your query was working fine when there was one record into the table but when there was more then one record into the table it was giving error "ORA-01427: single-row subquery returns more than one row". So i did small modification in the query as below
SELECT SUBSTR(' ' || name || ' ', INSTR(' ' || name || ' ' , ' ', 1, rn) +1,
INSTR(' ' || name || ' ' , ' ', 1, rn + 1) - INSTR(' ' || name || ' ' , ' ', 1, rn) -1) name
FROM test , (SELECT ROWNUM rn FROM all_objects
WHERE ROWNUM <= ( SELECT distinct(LENGTH(name) - (LENGTH(REPLACE(name, ' ')))) / LENGTH(' ') + 1
FROM test ))
order by name
so above query is working fine with more than one record but there is another problem as i am explaining blow
Suppose there is table called "test" as follows
SQL> select * from test;
NAME
Rajendra kumar jain
syed azhar husain
Chander Shekhar Kumar
when i am putting above query it is giving result as follows
NAME
Chander
Kumar
Rajendra
Shekhar
azhar
husain
jain
kumar
syed
my requirement is that for complete full name like 'syed azhar husain' it should give
name
fist name : syed
middle name: azhar
last name: husain
first name: rejendra
middle name: kumar
last name: jain
first name: chander
middle name: shekhar
last name: kumar -
How to select one row in a table with radio button
Hi all.
I have a VO where there is an attribute (isDefault [String]) that identifies the default record in the view. The possible values are 'Y' for yes and 'N' for no. Obviously only one record can have the 'Y' value.
In my page I have created an ADF Table (with the usual data control drag & drop). I would to transform the default inputText of "isDefault" field with a selectOneRadio component in order to permit the user to select (and save contextually in the DB) the default row of this table.
Can you explain me how? I'm using JDeveloper 11.1.1.4.
Thanks in advance.
BaduelBaduel wrote:
Cvele,
thanks for your responses. Yes, it's easier to use af:selectBooleanCheckbox but I need that the selection is mutually exclusive (only one row can be selected). >If this is possible also with the boolean checkbox please tell me how.- Let's try with CheckBox :
1. At the ViewObjectImpl level (for example, YourViewObjectImpl), add the following code:
private oracle.jbo.Key currSelectedRowKey = null;
public void doRowSelection(Key newKey) {
// de-select old one
if (currSelectedRowKey != null) {
Row[] rows = findByKey(currSelectedRowKey, 1);
if (rows != null && rows.length > 0)
rows[0].setStatusAsBoolean(Boolean.FALSE); // cast to the appropriate row Impl class if need !
// remember a new selected row key:
currSelectedRowKey = newKey;
}In the ViewRowImpl, in the transient attr settter, do as follows:
public void setStatusAsBoolean(Boolean value) {
setStatus(value.booleanValue() ? ONE : ZERO);
if (value.booleanValue()) {
YourViewObjectImpl vo = (YourViewObjectImpl)getViewObject();
vo.doRowSelection(getKey());
} P.S. The above was not tested at all, but should give you an idea -
ALV grid - how to break a long string into several lines?
I have a ALV grid, where one of the fields contains a textstring that is typically 100 characters long.
Is it possible to break this long string into shorter strings on multiple rows?
Kind of like in Excel, when using row break...Thats not possible in ALV
-
How to break up a String into multiple array Strings?
How do I break up a string into a bunch of String arrays after the line ends.
For example,
JTextArea area = new JTextArea();
this is a string that i have entered in the area declared above
now here is another sting that is in the same string/text area
this is all being placed in one text field
Sting input = area.getText();
now how do I break that up into an array of strings after each line ends?Ok I tested it out and it works.
So for future refrence to those that come by the same problem I had:
To split up a string when using a textfield or textarea so that you can store seperate sections of the string based on sperate lines, using the following code:
String text = area.getText() ;
String[] lines = text.split("\n") ;
This will store the following
this is all one
entered string
into two arrays
Cheers{
Edited by: watwatacrazy on Oct 21, 2008 11:06 AM
Edited by: watwatacrazy on Oct 21, 2008 11:16 AM
Edited by: watwatacrazy on Oct 21, 2008 11:16 AM -
How to separate one ITunes account into 2.
When I bought my son an iPod touch last year I just set it up using my existing Apple ID. Now I would like to separate them so I only see my things and he only sees his. How do I do that?
You will have to create a new Apple ID for your son, assuming that he is at least 13 years old. You can't split one Apple ID into 2.
-
Hi there,
I am working on my thesis with several Pages documents (for the first time). And I really have searched all over the Internet to find an answer to exactly my question but I cannot find it.
First my question was: How can I import one Pages document into another one? I found the answer on that (I think) and there is nothing else than just make a new section and copy/paste it in.
But then another issue pops up: I cannot [cmd]+A my whole document including the texboxes to paste it in the other Pages document. Then the document will be paste without the textboxes (and I have quite a lot of them in that document) and the text will not be at the right place.
So please explain to me: How I can combine two Pages documents and keep them exactly the way they are? Is that even possible?
I thank you so much in advance!Hi Fruhulda,
I have already tried to mark the textboxes in line but that did not work, and besides then the text and the boxes won't be at the rigt places either. Thank you for your reply . -
How just return one row of a one to many join..
So I have a one to many join where the SMOPERATOR table has data I need however it has a couple of rows that match the JOIN condition in there. I just need to return one row. I think this can be accomplished with a subquery in the join however have not been able to come up with the right syntax to do so.
So:
SELECT "NUMBER" as danumber,
NAME,
SMINCREQ.ASSIGNMENT,
SMOPERATOR.PRIMARY_ASSIGNMENT_GROUP,
SMOPERATOR.WDMANAGERNAME,
SMINCREQ.owner_manager_name,
SMINCREQ.subcategory, TO_DATE('01-'||TO_CHAR(open_time,'MM-YYYY'),'DD-MM-YYYY')MONTHSORT,
(CASE WHEN bc_request='f' THEN 'IAIO'
WHEN (bc_request='t' and substr(assignment,1,3)<>'MTS') THEN 'RARO'
WHEN (bc_request='t' and substr(assignment,1,3)='MTS') THEN 'M'
ELSE 'U' end) as type
from SMINCREQ
left outer join SMOPERATOR on SMINCREQ.assignment=SMOPERATOR.primary_assignment_group
WHERE SMINCREQ.owner_manager_name=:P170_SELECTION and SMOPERATOR.wdmanagername=:P170_SELECTION
AND open_time BETWEEN to_date(:P170_SDATEB,'DD-MON-YYYY') AND to_date(:P170_EDATEB,'DD-MON-YYYY')
AND
(bc_request='f' and subcategory='ACTIVATION' and related_record<>'t')
OR
(bc_request='f' and subcategory<>'ACTIVATION')
OR
(bc_request='t' and substr(assignment,1,3)<>'MTS')
order by OPEN_TIMeHi,
This sounds like a Top-N Query , where you pick N items (N=1 in this case) off the top of an orderded list. I think you want a separate ordered list for each assignment; the analytic ROW_NUMBER function does that easily.
Since you didn't post CREATE TABLE and INSERT statements for your sample data, I'll use tables from the scott schema to show how this is done.
Say you have a query like this:
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
ORDER BY dname
;which produces this output:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7934 MILLER CLERK 1300
ACCOUNTING 7839 KING PRESIDENT 5000
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
RESEARCH 7902 FORD ANALYST 3000
RESEARCH 7566 JONES MANAGER 2975
RESEARCH 7369 SMITH CLERK 800
RESEARCH 7788 SCOTT ANALYST 3000
SALES 7521 WARD SALESMAN 1250
SALES 7844 TURNER SALESMAN 1500
SALES 7499 ALLEN SALESMAN 1600
SALES 7900 JAMES CLERK 950
SALES 7698 BLAKE MANAGER 2850
SALES 7654 MARTIN SALESMAN 1250Now say you want to change the query so that it only returns one row per department, like this:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
SALES 7499 ALLEN SALESMAN 1600where the empno, ename, job and sal columns on each row of output are all taken from the same row of scott.emp, though it doesn't really matter which row that is.
One way to do it is to use the analytic ROW_NUMBER function to assign a sequence of unique numbers (1, 2, 3, ...) to all the rows in each department. Since each sequence startw with 1, and the numbers are unique within a department, there will be exactly one row per departement that was assigned the numebr 1, and we''ll display that row.
Here's how to code that:
WITH got_r_num AS
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
, ROW_NUMBER () OVER ( PARTITION BY d.dname
ORDER BY e.ename
) AS r_num
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT dname
, empno, ename, job, sal
FROM got_r_num
WHERE r_num = 1
ORDER BY dname
;Notice that he sub-query got_r_num is almost the same as the original query; only it has one additional column, r_num, in the SELECT clause, and the sub-qeury does not have an ORDER BY clause. (Sub-queries almost never have an ORDER BY clause.)
The ROW_NUMBER function must have an ORDER BY clause. In this example, I used "ORDER BY ename", meaning that, within each department, the row with the first ename (in sort order) will get r_num=1. You can use any column, or expression, or expressions in the ORDER BY clause. You muight as well use something consistent and predictable, like ename, but if you really wanted arbitrary numbering you could use a constant in the analytic ORDER BY clause, e.g. "ORDER BY NULL". -
How to write one row of data at a time to "Write to File"
I am trying to write 10 parameters to the LV "Write to File". This is for just one row at a time. This happens evertime I get a failure in my test routine. I am not quite sure how to accomplish this task. If I get another failure I write one row again. I testing 4 DUTS at a time so I write this row of data to each file. I am sure it is very simple.
Thanks
PhilipAssuming your 10 parameters are an numeric array with 10 elements, use "write to spreadsheet" file with append set to true. (... and if they are scalars, built the array first ).
LabVIEW Champion . Do more with less code and in less time . -
How to pass one row of a result set to a cffunction?
I can pass the entire result set of a query to a cffunction,
but the function only needs one row.
The code below is a syntax error, where "3" is array index
notation for the third row of the result set.
What is the correct way to pass one row of a result set to a
cffunction?
Thank you.iirc, cf does not allow one to reference and access a row of
a resultset
like that.
you will have to create a structure/array that holds the data
from
specific query row and pass that to your function. looping
over
queryname.columnlist list will make it easier and not
specific to any
particular query. make it into another function that accepts
a query and
row number as arguments and returns a struct/array of that
row data (or
automatically passes it to another function).
sample code for creating a structure of specific query row
data:
<cfset rowstruct = {}>
<cfloop list="#queryname.columnlist#" index="col">
<cfset rowstruct[col] = queryname[col][somerownumber]>
</cfloop>
<cfdump var="#rowstruct#">
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Maybe you are looking for
-
Since upgrading to IOS 7 the photographs I take on my iPhone 4S do not transfer to the cloud. Sometimes one or two of them transfer but then none for weeks. I have deleted photos from the cloud in case it is full but to no affect. I use my iPhone in
-
SBO Bank Statement Processing open A/R Invoice not visable
Hello, While processing Bankstatements we cannot select open invoices which were paid BEFORE they were created...... But when we select the businessparter we can see the open A/R Invoice so they exist as well in the system. Is there a solution ? Than
-
Can no longer enlarge or shrink the screen.
-
Report Scheduling. How to syncronize the GMT and the local server timezones
Hi everybody, I need to schedule reports using the Schedule tab on BIP, but I didn't still understand how the syncronization between my server's timezone and the GMT timezone works..... I noticed that when I open the Report Schedules initial page, th
-
Receiving Group Text : How do i see who else is in the distribution list???
Receiving Group Text : How do i see who else is in the distribution list??? other phones seem to have this, how can i see this? Post relates to: Pre p100eww (Sprint)