analytical query to select the next record
Hi allI would like to ask the two table below correspond to the output.
1.dev_wt 2.dev_map 3. output result
To help more clearance, please see this image link: http://lh6.ggpht.com/_xL6eBqjW6Yo/TEqnSvlF_FI/AAAAAAAAB0U/i2sclnnaj6g/Untitled-3.jpg
1 dev_wt
PMS_COMP PMS_I PMS_PERF_D PMS_WT PMS_CREATION_D
BBOARD GICEQGROSS 04/01/2001 30 04/05/2001
BBOARD GICST_B 04/01/2001 5 04/05/2001
BBOARD SBGS_B 04/01/2001 65 04/05/2001
BBOARD GICEQGROSS 04/11/2001 30 04/15/2001
BBOARD GICST_B 04/11/2001 5 04/15/2001
BBOARD SBGS_B 04/11/2001 65 04/15/2001
2 dev_mapGS_CODE GS_I_CODE GS_I_ID MD_ID GS_START_DT GS_END_DT
GICEQGROSS CIWL 304 15 01/04/1998 31/03/2004
GICEQGROSS CIWL 304 2 01/04/2004 31/03/9998
GICST_B GICST_B 3707 15 01/04/2000 31/12/9998
SBGS_B SBGS_B 2231 15 01/04/1992 30/09/2003
SBGS_B SBGS_B 564 15 01/10/2003 31/12/9998
I would like to match PMS_I = GS_CODE to retrieve the GS_I_CODE and analytical assistancequery to search for the next record.
Because I need to select record GICEQGROSS PMS_PERF_D date and following
GICEQGROSS save PMS_PERF_D of dev_wt table and put the result GS_WT_FR and GS_WT_TO output.
The date is in the format YYYYMMDD
PMS_WT is divided by 100
* 3. Output result *.
GS_I_ID PMS_COMP GS_I_CODE GS_WT_FR GS_WT_TO GS_I_CALC
304 BBOARD CIWL 20010401 20010410 0.3
3707 BBOARD GICST_B 20010401 20010410 0.05
5209 BBOARD SBGS_B 20010401 20010410 0.65
PMS_COMP is of dev_wt tableGS_I_CODE is dev_map join of tables with dev_wt
GS_WT_FR is dev_wt GS_START_DT table
GS_WT_TO's dev_wt record table according GS_START_DT where PMS_I = 'GICEQGROSS. '
Now my challenge is to select the next record in PMS_PERF_D using the query analysis. Below
is my query...
SELECT GS_I_ID, PMS_COMP, GS_I_CODE, GS_WT_FR, GS_WT_TO, GS_I_CALC
FROM dev_wt (
SELECT lead(PMS_PERF_D) over(partition by PMS_I order by PMS_PERF_D) as GS_WT_TO
FROM dev_wt where PMS_I ='GICEQGROSS')
left join dev_map on PMS_I = GS_CODE ;
Thank youEdited by: WinZone 24 July 2010 16:46
Edited by: WinZone 24 July 2010 16:50
Hello
This should be good:
SELECT DISTINCT t2.gs_i_id, pms_comp, t2.gs_i_code,
TO_CHAR
(MIN (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i),
'yyyymmdd'
) gs_wt_fr,
TO_CHAR
(MAX (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i) - 1,
'yyyymmdd'
) gs_wt_to,
pms_wt / 100 gs_i_calc
FROM dev_wt t1, dev_map t2
WHERE t2.gs_code = t1.pms_i
REM note even as odie: should be "2231" instead...
Tags: Database
Similar Questions
-
Help with the query to select only one record from the result set in double
Hello
Please help with the query. Version of Oracle database we use is 10g R2.
I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec
ID Org DF Sec Sub-Sec (163) CQ CPDM CPDM HD (163) PC ENG ENG ENG (163) CQ ASIC ASIC IS 8888 TS TAC TAC TAC (163) TS HE HE SW 6789 CQ INFO INFO FOS 6789 PC SECSYS SECSYS INFO1 6789 TS SECSYS SECSYS INFO2 9009 PC BMS BMS BMS1 My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.
ID DSB DF SEC Sub-Sec (163) CQ CPDM CPDM HD 8888 TS TAC TAC TAC 6789 CQ INFO INFO FOS 9009 PC BMS BMS BMS1 Thank you
Orton
Hello
This sounds like a job for ROW_NUMBER:
WITH got_r_num AS
(
SELECT id, DSB, df, s, sub_sec org
ROW_NUMBER () OVER (PARTITION BY ID.
ORDER BY org
) AS r_num
OF view_x
)
SELECT id, DSB, df, sub_sec s,
OF got_r_num
WHERE r_num = 1
;
He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data. (I know that you said that you were a view selection. Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places. (I didn't quite understand the explanation above. I don't know why you want toID ORG DF DRY SUB_SEC
-- --- -- --- -------
1234 CQ DPRK DPRK HD
and is not
1234 IS CQ ASIC, ASIC
or
TS 1234 IT IT SW
or
1234 CQ ASIC ASIC HD
)
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
I need a query that selects the amount of records for each day of a table.
I need a query that selects the amount of records for each day of a table.
For example, the result would be:
1 14 date
Date 2-3
etc.
Any ideas?Sort:
SELECT count ([IDCommentaire]), convert (varchar, dateAdded, 112)
OF COMMENTSgroup by convert (varchar, dateAdded, 112)
-
PHP (go to the next record in the database)?
Is there a php function that will move to the next record in a database and return to the page so that it looks out of date?
Here is my senario.
I have 30 events in a database from January 10, 2012, through to December 20, 2012, listed by date of-10-01-2012, 2012-12-20 etc.
On the homepage of Web sites, I want to list the 3 dates "next". Obviously January 10 has expired but is still listed in the database. The simplest would be to delete the record from the database, I suppose, but I was wondering if I can automate the process?
I can list 3 dates starting with a record in the database with owner of DW php code:
<? PHP {? >}
< div class = "event" >
<? PHP
echo $row_rsEvents ["event_date"]. "< br / > ';
echo $row_rsEvents ['event'],' < br / > ';
echo $row_rsEvents ["event_details"];
? >
< / div > <! - end event - >
<? PHP} while ($row_rsEvents = mysql_fetch_assoc ($rsEvents));? >
I can't hide an expiration date by comparing the date in the database with the current date
<? PHP
$date = date('Y-m-d');
? >
<? PHP {? >}
< div class = 'event' <? PHP if ($date > $row_rsEvents ['event_date']) {echo "style =" display: none;} "" ;} ? > >
<? PHP
echo $row_rsEvents ["event_date"]. "< br / > ';
echo $row_rsEvents ['event'],' < br / > ';
echo $row_rsEvents ["event_details"];
? >
< / div > <! - end event - >
<? PHP} while ($row_rsEvents = mysql_fetch_assoc ($rsEvents));? >
However it then shows just 2 dates in the form of code still loops through the records since the beginning of the database.
Any ideas or pointers?
Operating system
Why don't you do this in the SQL when you select the Recordset? You can specify WHERE date > = CURRENT_DATE in the SQL string. Then, you don't have to worry about this in the PHP.
-
Conditional Sum and look to the next record
First of all, here is an example of XML structure
& lt; game DATA & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 1 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 30 & lt; / FEES & gt;
& lt; DIVISION & gt; displayed title & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 1 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 20 & lt; / FEES & gt;
& lt; DIVISION & gt; Displays Title2 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 1 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 40 & lt; / FEES & gt;
& lt; DIVISION & gt; title displayed 3 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 2 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 30 & lt; / FEES & gt;
& lt; DIVISION & gt; visible title 5 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 2 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 80 & lt; / FEES & gt;
& lt; DIVISION & gt; displays title 6 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 3 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 90 & lt; / FEES & gt;
& lt; DIVISION & gt; displays title 7 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 3 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 90 & lt; / FEES & gt;
& lt; DIVISION & gt; displays title 8 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; DATASET_ROW & gt;
& lt; DEPARTMENT & gt; 4 & lt; / DEPARTMENT & gt;
& lt; FEES & gt; 30 & lt; / FEES & gt;
& lt; DIVISION & gt; displays title 9 & lt; / DIVISION & gt;
& lt; / DATASET_ROW & gt;
& lt; / Group DATA & gt;
Is it possible to get a sum of a field, grouped by two different fields? Example in my RTF, I have a repeating group based on the DIVISION that inserts section breaks. In the example I posted here what I have in my RTF model is an amount of TAX (guess there are several records for the DIVISION if only 1 is shown here) which appears on each page for the current group. Each DIVISION is printed on its own page. However, at the end of each DEPARTMENT, I also need to print a summary total of the sum of the FEES on all records for this DEPARTMENT on the same page as the last page of the last DIVISION.
So far, I have so he can make the subtotals for each DEPARTMENT, as they are in my loop. The tricky part, I'm not sure better to go to get and display the total general conditional. My original idea was to use a variable and do it manually in my template, but then I relaized I didn't know how to find out if the next record is the first record in the next Department or not. In this case, I'm hoping to stick in the field of the use of the straight lines of SQL query as my datasource because it's already done. The other option I considered was nested loops and a data model, but then I realized that I wasn't too sure to manually insert section breaks.
Any thoughts?I sent you the model back changed,
Let me know if that solves the question ;)
-
Why do I need to select the next button twice to move forward in my quiz
I have a number of true/false and multiple choice questions in this project. The user still has 2 attempts to get the correct answer with your comments. When they are done with the question they are asked to select the button "next". Selecting the next button does not advance the slide of the first time well. You must always select a second time. I played with adjust active and inactive times on the timeline, but that doesn't seem to have anything to do with it. Remove the 'next' button is not an option at this stage because it is mentioned in the audio commentary for each answer to each question. Any ideas?
If you insert a slide of questionnaire based on the model of default slides, normal stacking order is that the next button is below the Clear key. Maybe you had already removed the Clear button? Try to use Arrange to change the stacking order.
You do not click the next button twice, you must click the button submit once, then press on Y or click the slide. If the suspension point is far from the end of the slide, it will take a while, if actions are left to "continue". Change the point to pause to be near the end of the slide.
-
How can I restore and proceed to the next record.
Hello gurus. I have the procedure, my question is if I get the error in the loop to say to the 5th record. How can I skith who rank and proceed to the next record in the loop. I tried save points. your help is appreciated.
[code]
procedure insert_model1 is
exception of E2;
Start
because me in 1... 10 loop
Start
SAVEPOINT s1;
Insert in model 1
(MODEL_ID, MODEL_SEQ, P_IND)
values
(i, i + 1, 'U');
-calling an another procedure
insert_model2('Y');
If I = 15 then
lift e2;
end if;
-commit;
end;
end loop;
commit;
exception
When e2 then
Restore s1;
dbms_output.put_line (sqlerrm |) ',' || SQLCODE);
while others then
Restore s1;
-restoration;
dbms_output.put_line (sqlerrm |) ',' || SQLCODE);
end insert_model1;
[/ code]
My question is if I get the error in the loop to say to the 5th record. How can I skith who rank and proceed to the next record in the loop. I tried save points.
You tried save points, but you have done the restoration outside of the loop.
You must perform the restore in an exception inside the loop block.
Start
because me in 1... 10 loop
Start
SAVEPOINT s1;
Insert in model 1
..
EXCEPTION
...
RESTORE s1;
END;
end loop;
-
How to select the next item in a table view?
Hey,.
I want to select the next item, but I have no idea about it? have you any suggestions?
for example:
the second element is currently selected, I need to select the third in my code, how can I implement this feature?private IntegerProperty index = new SimpleIntegerProperty(); public final double getIndex() { return index.get(); } public final void setIndex(Integer value) { index.set(value); } public IntegerProperty indexProperty() { return index; }
Get the selected item:
table.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldvalue, Object newValue) { Person selectedPerson = (Person) newValue; setIndex(data.indexOf(newValue)); } });
Select the following index:
table.getSelectionModel().select(index.get() +1 );
-
Need to set the attribute of the current record based on the value of the next record
With the help of forms 6, I have a form that displays the list of folders. There may be multiple records with the same ID, but with different expiration dates. I need set attributes for hilite only the record with the latest expiration date. The current list points of interest reviews of future expiration dates - but we found that, sometimes, the subscription is renewed before the expiration date has been reached, causing two records with the same ID with expiry dates in the future.
I can (and do) sort the records by date of expiry and the identification for the record with the latest expiration date is always the last to this ID, so what I want to do is to check the next record to see whether or not it has a different ID. If the current record is the last expiration date, & must be hilited. Because I might want to hilite the current record, I can't simply navigate to another record, according to the description I found, what makes the next_record builtin. Anyone know how I can check for a value in the next record without making the current record?
Thank you.What I would do:
-Create a DB view based on your table and including the function call DRIVE as a separate column.
-Base that block you on this point of view
-If the block is modifiable, set the DML target for the block to your database table. -
Select the last record of each month
Hello
to select the last docnumber and qty of every month
Structure
Name Null? Type
------------------------------- -------- ----
PRODUCTCODE NUMBER
NUMBER NUMBER
DATE OF PLANFORMONTH
NUMBER OF CLEXPECTEDQTY
NUMBER OF CLCONFIRMQTY
NUMBER OF CLFGBUFFERQTY
NUMBER OF CLTOTPRINTBUFFER
in this select query if I take the sum he required all records where, as I want the last record of each month
SELECT productcode docnumber MAX (Number), planformonth, SUM (clexpectedqty) clexpectedqty (planformonth) MAX.
SUM (clconfirmqty) clconfirmqty, SUM (clfgbufferqty) clfgbufferqty, cltotprintbuffer OF FGSALESPLAN of the SUM (cltotprintbuffer)
GROUP BY productcode, (planformonth)
Sandy
Hello
Thanks its working now the code is written as below:
SELECT * FROM
(SELECT
e.*,
ROW_NUMBER() OVER (partition by PRODUCTCODE by DOCNUMBER DESC order) r
Of
E FGSALESPLAN)
WHERE r = 1 AND
entryvalid = 'Y '.
order by Number
Sandy
-
SQL query to retrieve the same record because no. boxes
Hi all
I have a table of Bill XXINV.
the columns are
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1123 XXITEM2 2 6
I can do a sql query so that I can retrieve the same records repeated as number INVH_BOXES.
Select * from XXINV
where invh_no = 1122
output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
Desired output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
or
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 1 of 5
1122 XXITEM1 1 2 of 5
1122 1 3 5 XXITEM1
1122 XXITEM1 1 4 of 5
1122 XXITEM1 1 5 of 5
Please suggest. Like I need to print each line in a single page to stick them on boxes so that packaging.
Kind regards
Afzal.
Just add INVH_ITEM_CODE to the connection by the clause.
Select invh_no
invh_item_code
invh_qty
to_char (, 'fm99') | 'from ' | TO_CHAR (invh_boxes, 'fm99') invh_boxes
of xxinv
where invh_no = 1122
connect
by level<=>=>
and prior invh_item_code = invh_item_code
and prior sys_guid() is not null
-
In the following query, I want only one record for Robert (later) and a record for all peoples in R1. Tried several joins, but do not know why it does not work
drop table r1;
create table r1
(
index_id NUMBER,
first name VARCHAR2 (10),
created DATE by DEFAULT SYSDATE
);
Insert into r1 (index_id, name) VALUES (1, 'Joe');
Insert into r1 (index_id, name) VALUES (2, 'Robert');
Insert into r1 (index_id, name) VALUES (3, 'John');
commit;
drop table r2;
create table r2
(
index_id NUMBER,
Field1 VARCHAR2 (10),
VARCHAR2 (10) Field2.
created DATE by DEFAULT SYSDATE
);
Insert into r2 (index_id, Field1, Field2) VALUES (2, "REC1", "OLD");
Insert into r2 (index_id, Field1, Field2, created) VALUES (2, 'REC1', 'NEW', sysdate + 1);
commit;
Select r1.*, r2.* from r1, r2,
(
Select f.index_id as ind, f.field1, max (f.created) as last
R2 f
F.index_id, f.field1) abc
where r1.index_id = r2.index_id
and r2.created = abc.latest
and r2.index_id = abc.ind (+);
.
Like this?
-------------------------------------------------------
SELECT *.
SINCE r1,.
(SELECT f.index_id AS ind, f.field1, MAX (f.created) AS last
R2 f
F.index_id, f.field1) r2
WHERE r1.index_id = r2.ind (+);
-------------------------------------------------------
INDEX_ID FIRST NAME CREATED IND FIELD1 LATEST 2 Robert 04/07/2013-06:43 2 REC1 05/07/2013-06:43 3 John 04/07/2013-06:43 1 Joe 04/07/2013-06:43 If not then please post your results
See you soon,.
Manik.
-
Presentation of the form of the ADF - navigation by jumping the next record.
I have a hard time trying to implement a feature using ADF. Please see my below use case and advise.
Use case:
To view the questions and capture responses (yes/no).
I use a formatting for data (questions to show) collections and adding the Yes buttons, not to enter the answers. The part I'm having trouble is: based on the answer to a particular question, there may be questions void to the question of the mother who may or may not be displayed according to a business logic. All questions and sub-questions are in the same table. The subquestions should not be displayed, should I remove them from the collection of data, so that when I click on the button 'Next' to go to the next question of parent. How to hide or show not the few recordings following, in a collection of data with navigation controls and put in shape.
Thank you.Your previous post has a possible answer. If you update an attribute on the records of the Sub, then when the user clicks the next button you can browse the lines and the value of the current row to the next question with the correct value of the attribute.
You have an attribute - 'IsDisplayed. Answer to question 2 and press Next.
(1) if the condition is met - set the IsDisplayed to 'False' flag on the issues 3 & 4.
(2) crosses the lines until you find the record following IsDisplayed flag = "Y". In this case, it would record 5.
(3) select this row as the current row in the collection.
(4) at this stage, the form should display the current line (form 5) -
Hello
I have a form that should display the name and the Qualification (2 text boxes) a table say PDetails.
One entry at a time
I want to create two buttons in the form 'Next' and 'previous '.
When I click on the button 'Next', it must retrieve the next row
and for the 'Previous', previous row button.
(It's there implicitly, forms when we give the query and all, but I want to create explicitly two buttons)
Any help?
AdkinsYou can view the built-in feature of oracle read image file image. Just search on forms help keyword READ_IMAGE_FILE. So you can give the path that is in this area and you will need to create an ELEMENT of IMAGE non-base of data in the same block and the trigger will work for that "WHEN NEW-RECORD-INSTANCE" at the block level.
-Clément
-
Tabular layout - what tab, do not go to the next record?
I use the Layout Wizard to create a form with article 2 (relationship master / detail). In the detail section, I build the layout as a table with the list of 7 lines with scroll bar. Each row in the table has 6 field. I enter a value in the first field, then tab, it goes to the next field, as expected... but when I tab after the last field of each line, he isn't going to the next row.
What did I miss?
Try this. Maybe you are sitting at the last record already and need to do a create_record:
If: system.cursor_item = ' EMPLOYEE. Last_name' then
If: system.last_record = "TRUE" then
create_record;
on the other
next_record;
end if;
on the other
next_item;
end if;
Maybe you are looking for
-
I just moved to the Italy. I had my HP Pavilion p6230f than Desktop shipped here from the United States with my other household items, and now I'm not sure what I have to plug it into Italian eletricity. Do I need a transformer, or simply an adapt
-
Options and accessories for my satellite A30-514
I can't find a Kit of floppy USB drive for my satellite A30-514Please help me.
-
Interruptions take up 50% of the time processor
Hi all I was looking around and I don't know exactly what is at issue here, but it is certainly something interesting. Problem is, from time to time the system starts very slowly, I have three or four processor intensive applications open or not, som
-
How can I reinstall Windows 7?
Original title: re - download windows 7 I bought the upgrade to windows 7 when there was agreement on students. so I have upgraded from vista to windows 7 and everything was fine. just recently, my broken hard drive and my laptop was still under warr
-
Windows visited - administrator password
What is the administrator password? You have to create a? Or like, what they are doing one? I need help. :(I want to download something, but he says that I have to type in a pssword...