unique several record based on the date record selection
Hi experts,
I have a table that contains multiple records for unique identification number now, I select the single record that contains the most recent date.
Here is the structure
Name of Type Null
------ ---- ------------
NUMBER OF ID_P
NAME_P VARCHAR2 (12)
DATE_P TIMESTAMP (6)
Reviews
---------------------
1 loosi 22 August 13 01.27.48.000000000 PM
1 hahahaha August 26, 13 01.28.10.000000000 PM
KK 2 22 August 13 01.28.26.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
now I have to select below 2 lines how to write select qurie for this?
1 loosi 26 August 13 01.27.48.000000000 PM
Emmeline 2 26 August 13 01.28.42.000000000 PM
Hello
You can use the ROW_NUMBER analytic function.
I don't have a copy of your table, so I'll use scott.emp to illustrate. In scott.emp, there may be several lines for a single job. To display only 1 row per job, hiredate line with the most recent:
WITH got_r_num AS
(
SELECT empno, hiredate-, deptno, job or whatever columns you want
ROW_NUMBER () taken OVER (PARTITION OF work
ORDER BY hiredate DESC
) AS r_num
FROM scott.emp
-WHERE--if you need a filter put it here
)
SELECT *- or the list of all columns except r_num
OF got_r_num
WHERE r_num = 1
;
What results do you want in the case of links? Depending on your needs, you can add expressions of tiebreaker to the analytical ORDER BY clause or the use of RANK instead of ROW_NUMBER.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
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.
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
Tags: Database
Similar Questions
-
Creating primary key based on the Date
Hi all
I am trying to create a unique ID for each record, based on the date that the record is created. Example, if the folder is created today, I want to the key is 20101130XX where XX is a sequential list of numbers e.g. 01, 02, 03 etc... in the case where more than one person creates a record today.
If 3 people created record yesterday their unique ID would be
2010112900
2010112901
2010112902
and then comes the midnight and someone creates a new record, that it would be
2010113000
This is intended to give each record with a unique ID that will be used to reference the ticket.
We are already using the date format, but currently users have to manually enter the id and who can create errors such as 2011112900 when it should have been 2010112900 then instead of 2010 they put 2011
I'm not sure how to create a trigger to generate this type of unique identification number and would appreciate any help
Thanks in advance
WallyNever said it was perfect, but then again, it is a rather sticky issue... Reset sequence work would be scheduled to run @ some point... You entered in tables past 24/7? I would say that system could be locked for those 5 minutes sequence is updated, or the table is locked to allow no access while the process is...
To be honest, that is the question in the design of a key value that is dependent on outside data, as apposed to a surrogate key, which is generated System... Again, you could have at ONCE and have the surrogate for a key key REAL primary and date + sequence as a secondary key for the use of basic unit of carbon...
Thank you
Tony Miller
Webster, TXIf vegetable oil is made from vegetables, then what is baby oil?
-
Get the old value and the new value based on the date
Hello
I have a table called list created below with the rest of the insert statements.
CREATE TABLE ROSTER
(
NUMBER OF ROSTER_EMPLOYEE_DEF_ID
NUMBER OF EMPLOYE_ID
NUMBER OF DEFINITION_REGION_CODE
NUMBER OF DEFINITION_DISTRICT_CODE
NUMBER OF DEFINITION_TERRITORY_CODE
START_DATE DATE,
END_DATE DATE
)
INSERT IN THE LIST
(ROSTER_EMPLOYEE_DEF_ID, EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE)
VALUES
(1,299,222,333,444, 'JUNE 1, 2011', 30 JUNE 2011 "")
INSERT IN THE LIST
(ROSTER_EMPLOYEE_DEF_ID, EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE)
VALUES
(2,299,223,334,445, "1 JULY 2011', JULY 20, 2011" "")
INSERT IN THE LIST
(ROSTER_EMPLOYEE_DEF_ID, EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE)
VALUES
(3,299,224,335,446, 'AUGUST 1, 2011', AUGUST 30, 2011 "")
INSERT IN THE LIST
(ROSTER_EMPLOYEE_DEF_ID, EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE)
VALUES
(4,300,500,400,300, 'JUNE 1, 2011', JUNE 20, 2011 "")
INSERT IN THE LIST
(ROSTER_EMPLOYEE_DEF_ID, EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE)
VALUES
(5,300,501,401,301, "1 JULY 2011', JULY 20, 2011" "")
In the table above we have columns like
EMPLOYE_ID, DEFINITION_REGION_CODE, DEFINITION_DISTRICT_CODE, DEFINITION_TERRITORY_CODE, START_DATE, END_DATE
The result I'm looking for the table above is based on the employe_id OF start_date AND end_date
I need to get the OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_CODE
Similarly, OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_REGION_CODE
and OLD_DEFINITION_TERRITORY_CODE and the NEW_DEFINITION_TERRITORY_CODE
I need to get a row of data for each employee saying old value and the new value
for the employee 299 there are 3 records he puts the new record which is the latest date is to say beginning August 1, 2011 and end date of recordings old 30 August 2011
beginning July 1, 2011 and July 20, 2011
For the data in the table above, I need to get the data as below
EMPLOYE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_CODE OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE START_DATE END_DATE
299 223 224 334 335 20 JULY 11 30 AUG 11
300 500 501 400 401 20 JUNE 11 JULY 20, 11
Please suggest me to get the result above, based on the data. Please let me know if my messages are not clear
Thank you
SudhirSELECT EMPLOYEE_ID, OLD_DEFINITION_REGION_CODE, NEW_DEFINITION_REGION_CODE, OLD_DEFINITION_DISTRICT_CODE, NEW_DEFINITION_DISTRICT_CODE, OLD_DEFINITION_TERRITORY_CODE, NEW_DEFINITION_TERRITORY_CODE, START_DATE, END_DATE FROM ( SELECT EMPLOYEE_ID, ROW_NUMBER() OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE DESC) RN, LAG(DEFINITION_REGION_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_REGION_CODE, DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE, LAG(DEFINITION_DISTRICT_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_DISTRICT_CODE, DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE, LAG(DEFINITION_TERRITORY_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_TERRITORY_CODE, DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE, LAG(END_DATE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) START_DATE, END_DATE FROM ROSTER ) WHERE RN = 1 / EMPLOYEE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE OLD_DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE OLD_DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE START_DAT END_DATE ----------- -------------------------- -------------------------- ---------------------------- ---------------------------- ----------------------------- ----------------------------- --------- --------- 299 223 224 334 335 445 446 20-JUL-11 30-AUG-11 300 500 501 400 401 300 301 20-JUN-11 20-JUL-11 SQL>
SY.
-
Find (weekly) missing date ranges based on the Date of submission
Nice day:
I have a table that contains the data with a date of presentation of the report column. If the requirements are that each employee must submit at least 1 weekly report beginning January 1, 2015, how can I find the weekly reports missing, based on the date of submission of reports.
The ideas that I had:
- Left join by partition by date (range between)
- Create a date dimension view?
Of course, I'm not sure how to approach this dilemma without creating a query of Monster. Sometimes the simplest queries mistake me...
Thank you, Aqua
Here are the DDL for the table with the information from the presentation report (example):
--------------------------------------------------------
-The DOF for Table DTS_FORM_SAMPLE
--------------------------------------------------------
CREATE TABLE 'DTS_FORM_SAMPLE '.
(NUMBER OF 'ID',
VARCHAR2 (20) "CLOCK_NUMBER."
NUMBER OF 'EMP_ID,'
NUMBER OF "REPORT_TYPE."
DATE OF THE "SUB_DATE.
) ;
/
INSERTION of REM in DTS_FORM_SAMPLE
TOGETHER TO DEFINE
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2896, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2897, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2898, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2899, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2900, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2901, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2902, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2903, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2904, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2920, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2921, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2922, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2923, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2924, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2925, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2965, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6970, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6971, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6972, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6973, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6978, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6979, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6980, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6981, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6948, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6957, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6958, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6959, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6960, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8938, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8939, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8940, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8941, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8942, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8943, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8977, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8978, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8979, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8980, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8981, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8982, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8983, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8984, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8985, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8953, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9824, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9825, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9826, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8972, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8973, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8974, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8975, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8951, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8952, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8954, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8955, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8956, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8957, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8958, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8959, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8960, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8961, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8962, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8963, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8964, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8965, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8966, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8967, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8968, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8969, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8970, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8971, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8976, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8986, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8987, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9041, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9042, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9043, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9044, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9045, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9046, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9047, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9048, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8944, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8945, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8946, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8947, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8948, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8949, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8950, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9527, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9528, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9529, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6739, 'YY7223', 11093,8, to_date('15-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6740, 'YY7223', 11093,8, to_date('21-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6741, 'YY7223', 11093,8, to_date('22-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6742, 'YY7223', 11093,8, to_date('25-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6743, 'YY7223', 11093,8, to_date('26-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6744, 'YY7223', 11093,8, to_date('27-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6745, 'YY7223', 11093,1, to_date('04-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6746, 'YY7223', 11093,1, to_date('11-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6747, 'YY7223', 11093,1, to_date('18-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6748, 'YY7223', 11093,1, to_date('25-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6749, 'YY7223', 11093,11, to_date('01-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6750, 'YY7223', 11093,11, to_date('15-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6751, 'YY7223', 11093,10, to_date('01-JUL-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11017, 'YY7223', 11093,1, to_date('07-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11018, 'YY7223', 11093,1, to_date('14-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11019, 'YY7223', 11093,1, to_date('21-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11020, 'YY7223', 11093,1, to_date('28-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11021, 'YY7223', 11093,1, to_date('04-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11022, 'YY7223', 11093,1, to_date('11-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11023, 'YY7223', 11093,1, to_date('18-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11024, 'YY7223', 11093,1, to_date('25-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11025, 'YY7223', 11093,10, to_date('31-MAY-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11026, 'YY7223', 11093,10, to_date('30-JUN-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13115, 'YY7223', 11093,1, to_date('13-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13201, 'YY7223', 11093,1, to_date('20-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13287, 'YY7223', 11093,1, to_date('27-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13373, 'YY7223', 11093,10, to_date('08-SEP-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13489, 'YY7223', 11093,8, to_date('01-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13490, 'YY7223', 11093,8, to_date('02-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13491, 'YY7223', 11093,8, to_date('03-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13492, 'YY7223', 11093,8, to_date('04-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13493, 'YY7223', 11093,8, to_date('05-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13494, 'YY7223', 11093,8, to_date('06-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13495, 'YY7223', 11093,8, to_date('07-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13496, 'YY7223', 11093,8, to_date('08-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13497, 'YY7223', 11093,8, to_date('09-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13498, 'YY7223', 11093,8, to_date('10-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13499, 'YY7223', 11093,8, to_date('11-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13500, 'YY7223', 11093,8, to_date('12-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13501, 'YY7223', 11093,8, to_date('13-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13502, 'YY7223', 11093,8, to_date('14-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13503, 'YY7223', 11093,8, to_date('15-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13504, 'YY7223', 11093,8, to_date('16-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13505, 'YY7223', 11093,8, to_date('17-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13506, 'YY7223', 11093,8, to_date('18-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13507, 'YY7223', 11093,8, to_date('19-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13508, 'YY7223', 11093,8, to_date('20-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13509, 'YY7223', 11093,8, to_date('21-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13510, 'YY7223', 11093,8, to_date('22-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13511, 'YY7223', 11093,8, to_date('23-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13512, 'YY7223', 11093,8, to_date('24-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13513, 'YY7223', 11093,8, to_date('25-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13514, 'YY7223', 11093,8, to_date('26-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13515, 'YY7223', 11093,8, to_date('27-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13516, 'YY7223', 11093,8, to_date('28-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13517, 'YY7223', 11093,8, to_date('29-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13518, 'YY7223', 11093,8, to_date('30-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13519, 'YY7223', 11093,8, to_date('31-AUG-15','DD-MON-RR'));
Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13030, 'YY7223', 11093,1, to_date('06-AUG-15','DD-MON-RR'));
--------------------------------------------------------
-Table DTS_FORM_SAMPLE constraints
--------------------------------------------------------
CHANGE ALTER TABLE 'DTS_FORM_SAMPLE' ('ID' ENABLE NOT NULL);
/
Or more simple:
Select emp_id, w.wk, to_char (wk, 'ww') x
from (select trunc (date ' 2015-01-01' + 7 * (level - 1), 'ww') wk)
of the double
connect by level<=>=>
) o
left outer join
s dts_form_sample
by (emp_id) partition
We trunc (s.sub_date, 'ww') = w.wk
where sub_date is null
order to emp_id,
x
/
EMP_ID WK X
---------- --------- --
11093 1ST JANUARY 15 01
11093 8 JANUARY 15 02
11093 15 JANUARY 15 03
11093 22 JANUARY 15 04
11093 29 JANUARY 15 05
11093 5 FEBRUARY 15 06
11093 12 FEBRUARY 15 07
11093 19 FEBRUARY 15 08
11093 26 FEBRUARY 15 09
11093 5 MARCH 15 10
11093 12 MARCH 15 11EMP_ID WK X
---------- --------- --
11093 19 MARCH 15 12
11093 26 MARCH 15 13
11093 2 APRIL 15 14
11093 9 APRIL 15 15
11093 16 APRIL 15 16
11093 23 APRIL 15 17
11093 30 APRIL 15 18
11093 37 15 - SEP - 10
17-SEVEN 11093.-15 38
24-SEVEN 11093.-15 39
11093 1 OCTOBER 15 40EMP_ID WK X
---------- --------- --
11093 8 OCTOBER 15 41
11093 15 OCTOBER 15 42
11093 22 OCTOBER 15 43
11093 29 OCTOBER 15 44
11093 5 NOVEMBER 15 45
11093 12 NOVEMBER 15 46
11093 19 NOVEMBER 15 47
11093 26 NOVEMBER 15 48
11093 3 DECEMBER 15 49
11093 10 DECEMBER 15 50
11093 17 DECEMBER 15 51EMP_ID WK X
---------- --------- --
11093 24 DECEMBER 15 52
11093 31 DECEMBER 15 53
12810 1ST JANUARY 15 01
12810 8 JANUARY 15 02
12810 15 JANUARY 15 03
12810 27 AUGUST 15 35
12810 15 - SEP - 03 36
12810 37 15 - SEP - 10
17-SEVEN 12810.-15 38
24-SEVEN 12810.-15 39
12810 1 OCTOBER 15 40EMP_ID WK X
---------- --------- --
12810 8 OCTOBER 15 41
12810 15 OCTOBER 15 42
12810 22 OCTOBER 15 43
12810 29 OCTOBER 15 44
12810 5 NOVEMBER 15 45
12810 12 NOVEMBER 15 46
12810 19 NOVEMBER 15 47
12810 26 NOVEMBER 15 48
12810 3 DECEMBER 15 49
12810 10 DECEMBER 15 50
12810 17 DECEMBER 15 51EMP_ID WK X
---------- --------- --
12810 24 DECEMBER 15 52
12810 31 DECEMBER 15 5357 selected lines.
SQL >
However OP question must answer is start of week date.
SY.
-
How to hide/show a field based on the data from more than 1 field?
Hello.
I'm trying to hide/show a based on the data of field2 and field3, Field1
in fact using dynamic measurements I can only hide/show Field1 Field2-based, but I need a combination, for example:
If field1 = 'A' and field2 = 'B', then see the field3, other hide field3
y at - it an easy way to do it.
I use Application Express 4.2.4.00.08
Thanks in advance
Dynamic action
On the changes
jQuery selector: #P1_ITEM_1, #P1_ITEM_2
Condition: JavaScript
$v ('P1_ITEM_1') == 'A' & $v ('P1_ITEM_2') == 'B '.
Real Action: show item 3
Action of false: hide item 3
-
How to plan the report filtered by dynamic date based on the date, the Agent is running
Hello
I have a question about account using OBIEE agent.
If I run an agent today to deliver A report, can I me A report based on the date of last Monday or any dynamic dates?
For example, say is today, December 18, 2013, and my agent is run according to how I put the calendar. Now the content of the delivery report one being delivered. Now A report has a date column, normally this column is filtered by the current date. But if it comes through the agents to different users, the data should be the previous Monday, so in this case, 9 December 2013. When this agent is run once again, declared December 27, 2013, then the report must be filtered by December 16, 2013, which is the previous Monday 27 dec.
Something like this is possible in OBIEE 11 G?
Thanks in advance.
Yala,
Not in a straightforward way
(1) let the report through Agent with filter current Date
(2) after he ran for the first time you can see IBOT name/last execution time (LAST_RUNTIME_TS) in S_NQ_JOB
Create a variable reference 'last_run_agent' to aid in sql to get max (LAST_RUNTIME_TS)
SELECT max (LAST_RUNTIME_TS) from s_nq_job, whose name = "AGENT_NAME;
Change analysis with current date filter report and amend accordingly the condition of filter to filter on repository variable, newly created
Thank you
-
5 digit unique random number based on the year
Hello
I need 5 digit unique random number based on the year. If the new year then duplicate random number allowed.
Thank youIf only 5-digit numbers are needed you can extract some transformation injective (http://en.wikipedia.org/wiki/Injective_function) and you could easily check for uniqueness:
substr (to_char (ln (sequence_value)), 10, 5)
substr (to_char (exp(1 / sequence_value)), 20, 5)
...Concerning
Etbin
-
Best results of 10 based on the date
Hello
I tried to find a way to get 10 rows of data based on the latest release dates, which is sort by newest in descending order. Here is the table and SQL that I use. By the way, I am using Oracle 10 g.
I used date_released in where clause for a little record to return because I have a lot of documents that leave from 2001.Tell me if my approach is wrong.SQL = SELECT movie.id, movie.name, movie.date_released,actor.actor_name, movie_type.type FROM movie INNER JOIN actor on movie.id = actor.movie_id INNER JOIN movie.id = movie_type.movie_id where date_released > '10-OCT-2008' and rownum <=10 order by date_release desc;
But I don't get the expected result. The result I get are not as expected. For example, it displays only from 20/04/2010 in descending order. What can I do it wrong? Your help will be greatly appreciated. Thank you.
Edited by: Software_Janitor may 27, 2010 05:31ROWNUM is assigned before the ORDER BY clause, which means that you cannot restrict your results by using ROWNUM in the same query in the ORDER BY. You must place the request with the ORDER BY in a subquery and filter results at the top of the page in the outer query like this:
SELECT * FROM ( SELECT
FROM WHERE ORDER BY ) WHERE rownum <= ; I tried to convert your example:
SELECT * FROM ( SELECT movie.id , movie.name , movie.date_released , actor.actor_name , movie_type.type FROM movie INNER JOIN actor ON movie.id = actor.movie_id INNER JOIN movie_type ON movie.id = movie_type.movie_id WHERE date_released > TO_DATE('10-OCT-2008','DD-MON-YYYY') ORDER BY date_release DESC ) WHERE ROWNUM <= :some_val ;
It's called a "Top - N" query Here is an article showing other alternatives: on Top-n and Pagination queries
I hope this helps!
Edited by: Centinul may 27, 2010 08:26
-
Calculation based on the date, but the year &; month on fileds separate.
Hello
Simple question:
I have a table with the SOURCE fields 9i, YEAR, MONTH
Because I don't have a date field, how I count for example records < 07/2008?
SAMPLE DATA:
.
.
.
APPLES; 2008; 06
APPLES; 2008; 07
APPLES; 2008; 08
.
.
.
Thanks in advance for your help.Hello
do you want this?with data as (select 'APPLES' SOURCE ,'2008' yy,'06' mm from dual union all select 'APPLES' ,'2008' ,'07' from dual union all select 'APPLES' ,'2008' ,'08' from dual) select count(*) from data where to_date(yy||mm,'YYYYMM') <= to_date('072008','MMYYYY')
-
Selection based on the date of no recovery no lines
Hello
Why this doesn't work (returns 0 records)
< cfquery = name 'interrogate' Datasource = "#Application.Datasource #" >
SELECT *.
THE VOTING
WHERE the arguments start_date > = #DateFormat (now (), "dd-mm-yyyy") # and end_date < = #DateFormat (now (), "dd-mm-yyyy") #.
< / cfquery >
There are two rows on the table. One with start_date 12/01/2006 and the date of 12/19/2006, the other with 12/20/2006 start_date and end_date of 31/12/2006. Any of these get selected, once the current DAT files are 31/12/2006.
Thank youMy lack of formal training is showing through... I jump into the deep end. I changed the statement for...
WHERE the #DateFormat (now (), "dd-mm-yyyy") # BETWEEN start_date and end_date
I read this as "where is today > = past date and today.<= future="" date".="" i="" want="" a="" date="" between="" the="" start="" and="" end.="" but="" that="" doesn't="" return="" any="">=>
What shocks you on the date format? JMA is the Australian date format.
I will start this topic.
Thank you
Tanya -
The smart Albums based on the date range cause app Crash Photos
While I'm setting up a new Smart Album based on day of photos between 12/01/2015 and 31/12/2015 the Photos app closes with a crash. Cannot set the second date (the end date for this album). However, I can easily create a new Smart Album for next month (01/01/2016 and 01/31/2016). I create smart Albums, because the new Photos app does not like the old iPhoto does with my Photos from the photo gallery.
How can I solve this? I don't have an album of December...? !
You are in an area where the date format is different from the United States? Earlier this year, we have seen small business issues have reported that rules for smart albums date range do not work with the primary language set to French or German.
Try to change the primary system language to English with an English date format. Photos could be trying to read the 12/31/2015 as the 12th day of the month 31.
Or use a different date based on 'before' rule and after.
-
Importing several files .csv in the data portal
I'm looking to import data that contains multiple .csv files in the data portal. I have a code to succeed, which can erase all data from the data portal, open a dialoge box to find new data and open new data using a .csv use. I want to improve this script to be able to have the ability to load multiple datasets in the data at a time portal, but I have a limited knowledge of the VBS coding structure. Can someone advise measures to reach this solution with VBS minimal coding experience? Thank you all in advance for your help.
Hi dc13.
The tiara FileDlgShow command has the ability to load several files at the same time. Please take a look by using tiara for more details and an example.
Greetings
Walter
-
Then the validation of a detail or form based on the date picker - upper effective Date?
Hi, creates a BP custom with the effective date in field added to my details form or higher. Can I have a set of validation rules up for my top of or the form detailed such as the effective date cannot be greater than the current date? Thanks in advance.
For the decimal amount, you need to change the formula type, the default value is a numerical formula, but you must choose the date difference. This is the online help:
To create a date-difference formula
- Open the form that contains the field for which you want to create a formula. The form designer window opens.
- In the form designer window, select the date field that you want to create the formula. When the calculation is performed, this field appears as read-only on the form and will automatically update each time that the fields that make up the formula change.
- Click the formula button. A creation of the formula window opens.
- In the formula field Type, choose the difference in Date in the list. The window expands to show additional fields, as shown in the table below.
- Click OK to save your changes and close the window.
In this area:
Follow these steps:
Last Date
Click on the arrow down. uDesigner displays the list of all numeric fields on the form. In this list, choose the field that contains the later of the two dates that will be used in the calculation.
Earliest date
Click on the arrow down. In this list, choose the field that contains the first of the two dates that will be used in the calculation.
Calculations based on
Choose the calendar days to include all days of the week in the calculation. Choose the days of work to use only the working days of the week in the calculation.
-
conditional merge based on the date
Need help on a merge statement. I need to merge two dataset. But when the key match, I also need to cpmpared the date before I merege it.
See code belowdrop table x1; drop table y1; select * from x1; select * from y1; create table x1 (id number,name varchar2(10),cdate date,status varchar2(1)); create table y1 (id number,name varchar2(10),cdate date,status varchar2(1)); insert into x1 select 1,'A',sysdate - 100,'Y' from dual; insert into y1 select 1,'A',sysdate - 50,'N' from dual ;--should change x1.status to y1.status and x1.cdate to y1.cdate as y1.cdate > x1.cdate insert into x1 select 2,'B',sysdate - 20,'Y' from dual; insert into y1 select 2,'B',sysdate - 120,'N' from dual ;--should leave status in x1 alone insert into y1 select 3,'c',sysdate - 10,'Y' from dual; --should do an insert on x1 commit; --how do I do a conditional merge (key=id,name) -- based on the cdate. If y1.cdate >= x1.cdate then take the y1.status and y1.cdate --desire output select * from x1 1 A 01/01/2012 10:54:35 AM N 2 B 1/31/2012 10:54:37 AM Y 3 C 1/31/2012 10:54:37 AM Y
Hello
You can add a WHERE clause to the WHEN MATCHED THEN UPDATE section.
WHERE x1.cdate < y1.cdate
Thanks for posting the CREATE TABLE and INSERT statements; It is very useful. It would also help if you have validated your MERGE statement, even if it does not work perfectly.
-
Capture the content of the pdf presentation and create a new document based on the data?
Are there programs that can capture the content of the pdf presentation and create a new document based on that? I want to convert the data from a pdf form to fill in an auto-generated shipping label. Thank you!
Only field names that match exactly. You can use JavaScript and hidden fields to match the names of domain if necessary.
-
APEX4: How to create a report whose data are based on the date of entry of the user fields
With the help of 4 Apex I create a report that allows the user to enter two dates and displays a report between the date range.
How can I do this?
Thank you.Go to Actions > filter in your IR and ther, you can create several conditions to filter your report.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
-------------------------------------------------------------------
Maybe you are looking for
-
How to prevent the tabs to open in a new window?
Given that I have updated to the latest version of Firefox, I am plagued with a problem, and I can't seem to stop. When I go back to Firefox and click on any tab, it almost always causes this tab open in a new window. It is a feature - drag a tab in
-
How can I transfer my bookmarks from IE to Foxfire
I have a long list of favorites on my Internet Explorer screen. How can I transfer this list intact on my Foxfire screen? I don't know which toolbar are my favorites, because it is not marked anything other than bookmarks. Could be Windows, Internet
-
Every time at startup my laptop wnts to install Photo Gallery, can't find it, and I have to go through a lot of operations "Cancel". The same thing happens when I want to play a DVD using VDX. Photo Gallery wants to start first and screw up the begin
-
How to contact go to support meeting
Contact support to attend the meeting How can I contact support go to the meeting?
-
Security problems of wireless network Windows Vista prevents connectivity
I recently bought a new wireless router and now my HP Compaq does not connect to the network. We discovered that this has to do with the security of the network. Y at - it a patch for Windows Vista fix the problems with the help of WPA/WPA2 Personal