Help required for PLSQL or with some Analytical Function.
Hello All
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
I have couple of questions with following dataset and insert into a table
With t As
SELECT '2011' YR, FN1 File_name,1 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,2 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,3 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,4 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,5 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,6 rec_seq From Dual Union All
SELECT '2012' YR, FN1 File_name,7 rec_seq From Dual Union All
SELECT '2011' YR, FN1 File_name,8 rec_seq From Dual Union All
SELECT '2010' YR, FN1 File_name,9 rec_seq From Dual
SELECT C_CAND_ID,MAX(C_CAND_ID) OVER (PARTITION BY C_CAND_ID ORDER BY YR) FROM
SELECT DISTINCT COUNT(*) OVER (PARTITION BY YR ORDER BY FILE_NAME) "C_CAND_ID",
YR
FROM
(select YR, FIle_name
from t
How to find year which is not equal to count with maximum year (2011) and insert into errorlog table
How to find all distinct years --- 2011, 2012 and 2010 and insert into error log table
Target table is
Create table errorlog
(Error_code number,
Errorheader varchar2(100),
error_details varchar2(1000),
rec_sequence number
output is
errorcode errorheader errordetails rec_sequence
1 Year not as maximum count The year 2012 not equal to 2011 the max count 7
1 Year not as maximum count The year 2010 not equal to 2011 the max count 9
2 distinct years are the distinct years are 2010,2011,2012 0
also I have couple of other questions like
How to find YR with maximum number of records ----- the answer should be 2011.
How to find count of distinct years ---- the answer should be 3
Please give me some guidence or help
Thanks
How to find year which is not equal to count with maximum year (2011) and insert into errorlog table
How to find all distinct years Maybe following query gives you a start to identify the necessary information:
SQL> with t as
select '2011' yr, 'fn1' file_name,1 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,2 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,3 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,4 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,5 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,6 rec_seq from dual union all
select '2012' yr, 'fn1' file_name,7 rec_seq from dual union all
select '2011' yr, 'fn1' file_name,8 rec_seq from dual union all
select '2010' yr, 'fn1' file_name,9 rec_seq from dual
select max (yr) keep (dense_rank last order by cnt_yr) over () max_cnt_yr, /* gives you the year with the most entries */
t.* /* rest of table */
from (select count (yr) over (partition by yr) cnt_yr, /* counts of a particular year ? */
count (distinct yr) over () cnt_distinct_yr, /* how many distinct years ? */
t.*
from t) t
MAX_CNT_YR CNT_YR CNT_DISTINCT_YR YR FILE_NAME REC_SEQ
2011 1 3 2010 fn1 9
2011 7 3 2011 fn1 2
2011 7 3 2011 fn1 3
2011 7 3 2011 fn1 4
2011 7 3 2011 fn1 6
2011 7 3 2011 fn1 1
2011 7 3 2011 fn1 5
2011 7 3 2011 fn1 8
2011 1 3 2012 fn1 7
9 rows selected.
Similar Messages
-
Help Required For HF100 Used With FCE 4 ?
No, it's not for me.
A few days ago Tom Bigley tacked this question onto another HF100 thread but it seems to have gone unnoticed, so I am reprinting it here:-
"Forgive me if I am going over old ground but I have just acquired a HF100 and want assurance I have understood the AVCHD/FCE relationship correctly.
I must use High Quality XP at 12Mbps (1440 x 1080)
I cannot use High Quality FXP (1920 x 1080)
I cannot use Cine and 25Mbps or I get into interlacing complications
I import using Easy SetUp set to Apple Intermediate Codec
with the Use Tab set to HDV-Apple Intermediate Codec 1080i50
Am I there or are there any other pitfalls I've overlooked?
Tom."Hello Richy
My first thought is, can't you just put the graphic elements in to the photo with your choice of editor?
It looks like you are trying to position two yellowy-green lines in the page as well. You could put one of those lines in to the image and one in the left panel as a background (I'm not absoulutely clear where they go but I think I've made a pretty good guess.)
You could try adding a header div and using a slice of the image as a background and position your logo elements in that with float, margin, padding or whatever.
Basically, you have a two column layout which is quite simple so there should be a solution.
You could try putting the main image as a background image and position your graphic elements in the content panel (div)?
If your main image is a background though, I think you might have a bit more difficulty with height so, you would have to perhaps use the left column content to determine height.
These are just a few thoughts but given with the caveat of my novice status! I've only just learned to tie my HTML shoe laces.
Good luck
Martin
PS I remember a few years ago now, bing advised through these pages to only use absolutely positioned elements if you really have no other alternative and then if you do, to only use one! Since then, I haven't ever used one.
PPS I like your design very much but I am not sure about that bright yellow text? The pink circle looks as though it should be crazy but it fits beautifully with your colour scheme. That yellow hits off it a bit in my mind and jars a little. -
What technlogy is good for ABAP developer with some littile knowdge of java
Hi Experts,
What technlogy is good for ABAP developer with some littile knowdge of java IN SAP NETWEAVER.
Can any one guide me for good technology for todays market.
Thanks
Edited by: sdnhelp on Jul 15, 2009 1:50 PM
Edited by: sdnhelp on Jul 15, 2009 1:51 PM
Edited by: sdnhelp on Jul 15, 2009 1:51 PMHi,
you can choose PI of netweaver.
Regards,
Muralidhar -
Is Photoshop in Photography packet full version or with some limited functionality?
Hello,
question is in the title
And one more - is Photography packet for everyone or just for those, who can prove they're photographers?
Thanks for help!Hi Jtk,
Ques1. Is Photoshop in Photography packet full version or with some limited functionality?
Ans1. In Photoshop packet you will be getting the full version of latest Photoshop CC2014.
For more details https://creative.adobe.com/plans
Ques2. Is Photography packet for everyone or just for those, who can prove they're photographers?
Ans2. It is for every one and you don't need to prove that you're a photographer .
Let me know if you more questions.
Thanks!
Eshant -
Wired problem with LEAD Analytical function
I am having wired problem with LEAD Analytical function. It works fine as a standalone query
but when used in sub-query it is not behaving as expected (explained below). I unable to troubleshoot
the issue. Please help me.
Detail explanation and the data follows:
========================= Table & Test Data =======================================
CREATE TABLE "TESTSCHED"
( "SEQ" NUMBER NOT NULL ENABLE,
"EMPL_ID" NUMBER NOT NULL ENABLE,
"SCHED_DT" DATE NOT NULL ENABLE,
"START_DT_TM" DATE NOT NULL ENABLE,
"END_DT_TM" DATE NOT NULL ENABLE,
"REC_STAT" CHAR(1) NOT NULL ENABLE,
CONSTRAINT "TESTSCHED_PK" PRIMARY KEY ("SEQ")
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (1, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (2, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (3, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (4, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:15:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (5, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:15:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (6, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (7, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (8, 39609, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 11:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (9, 118327, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (10, 120033, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('04-03-2008', 'dd-mm-yyyy'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (11, 120033, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('04-03-2008', 'dd-mm-yyyy'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (12, 120033, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (13, 120033, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (14, 126690, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 18:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 21:15:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (15, 126690, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 12:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 16:45:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (16, 126690, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 12:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 21:15:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (17, 126690, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 16:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 18:45:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (18, 126690, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 16:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 18:45:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (19, 169241, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 05:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 14:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (20, 169241, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 05:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 14:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (21, 169241, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (22, 169241, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (23, 200716, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (24, 200716, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (25, 200716, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (26, 252836, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (27, 252836, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (28, 252836, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (29, 252836, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 17:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 19:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (30, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 10:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (31, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 10:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 14:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (32, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 05:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (33, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:15:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 10:35:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (34, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:15:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 10:35:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (35, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 05:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 14:00:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (36, 260774, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 07:00:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 10:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (37, 289039, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 16:30:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:15:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (38, 289039, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 13:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 22:15:00', 'dd-mm-yyyy hh24:mi:ss'), 'I');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (39, 289039, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 13:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 16:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'A');
insert into testsched (SEQ, EMPL_ID, SCHED_DT, START_DT_TM, END_DT_TM, REC_STAT)
values (40, 289039, to_date('03-03-2008', 'dd-mm-yyyy'), to_date('03-03-2008 13:45:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('03-03-2008 16:30:00', 'dd-mm-yyyy hh24:mi:ss'), 'U');
========================= Problem Statement =======================================
Problem Statement:
Select all employees whose active schedule (rec_stat = 'A') start date & time falls
between "16:30" and "17:45".
An employee may be having multiple schedules on a day. It may be continuous or may be
having breaks in between the schedules.
If an employee schedule is continuous then the minimum schedule start date & time is
considered as the start date & time of the work.
If an employee is having breaks in the schedule, then each schedule start date & time is
considered as start date & time.
e.g:-1
1 39609 2008/03/03 2008/03/03 07:00:00 2008/03/03 11:00:00 A
2 39609 2008/03/03 2008/03/03 11:00:00 2008/03/03 11:30:00 A
In above case, the employee schedule is continuous. The start date & time is 2008/03/03 07:00:00
e.g:-2
19 169241 2008/03/03 2008/03/03 05:30:00 2008/03/03 14:00:00 A
21 169241 2008/03/03 2008/03/03 17:30:00 2008/03/03 22:00:00 A
In above case, the employee is having a break in between. Then both records
start date & time (i.e. 2008/03/03 05:30:00, 2008/03/03 05:30:00 ) is considered
as start date & time.
e.g:-3
30 260774 2008/03/03 2008/03/03 07:00:00 2008/03/03 10:30:00 A
31 260774 2008/03/03 2008/03/03 10:30:00 2008/03/03 14:00:00 A
32 260774 2008/03/03 2008/03/03 05:30:00 2008/03/03 07:00:00 A
In above case, the employee schedule is continuous. The start date & time is 2008/03/03 05:30:00
========================= Query to test Individual Employees =======================================
Query-1: Test query to see the CASE and LEAD function works fine. If "CAL = 0" means that all
schedules are continuous and the employee needs to ignored.
SELECT fw.*,
CASE WHEN LEAD(FW.END_DT_TM, 1)
OVER(ORDER BY FW.START_DT_TM DESC ) IS NULL AND
fw.start_dt_tm BETWEEN
TO_DATE('03/03/2008 16:30:00','mm/dd/yyyy hh24:mi:ss') AND
TO_DATE('03/03/2008 17:45:00','mm/dd/yyyy hh24:mi:ss')
THEN Fw.seq
WHEN LEAD(FW.END_DT_TM, 1)
OVER(ORDER BY FW.START_DT_TM DESC) != FW.START_DT_TM AND
fw.start_dt_tm BETWEEN
TO_DATE('03/03/2008 16:30:00','mm/dd/yyyy hh24:mi:ss') AND
TO_DATE('03/03/2008 17:45:00','mm/dd/yyyy hh24:mi:ss')
THEN Fw.seq
ELSE 0
END AS "CAL"
FROM TESTSCHED fw
WHERE fw.empl_id = 289039
and fw.rec_stat = 'A'
Query Results
SEQ EMPL_ID SCHED_DT START_DT_TM END_DT_TM REC_STAT CAL
37 289039 2008/03/03 2008/03/03 16:30:00 2008/03/03 22:15:00 A 0
39 289039 2008/03/03 2008/03/03 13:45:00 2008/03/03 16:30:00 A 0
Since all "CAL" column is zero, the employee should be ignored.
========================= Query to be used in the application =======================================
Query-2: Actual Query executed in the application which is not working. Query-1 is used as subquery
here.
SELECT
F1.SEQ,
F1.EMPL_ID,
F1.SCHED_DT,
F1.START_DT_TM,
F1.END_DT_TM,
F1.REC_STAT
FROM TESTSCHED F1
WHERE F1.SEQ IN
(SELECT CASE
WHEN LEAD(FW.END_DT_TM, 1)
OVER(ORDER BY FW.START_DT_TM DESC) IS NULL AND
FW.START_DT_TM BETWEEN
TO_DATE('03/03/2008 16:30:00', 'mm/dd/yyyy hh24:mi:ss') AND
TO_DATE('03/03/2008 17:45:00', 'mm/dd/yyyy hh24:mi:ss') THEN FW.SEQ
WHEN LEAD(FW.END_DT_TM, 1)
OVER(ORDER BY FW.START_DT_TM DESC) != FW.START_DT_TM AND
FW.START_DT_TM BETWEEN
TO_DATE('03/03/2008 16:30:00', 'mm/dd/yyyy hh24:mi:ss') AND
TO_DATE('03/03/2008 17:45:00', 'mm/dd/yyyy hh24:mi:ss') THEN FW.SEQ
ELSE 0
END
FROM TESTSCHED FW
WHERE FW.EMPL_ID = F1.EMPL_ID
AND FW.REC_STAT = 'A')
Query-2 Results
SEQ EMPL_ID SCHED_DT START_DT_TM END_DT_TM REC_STAT
9 118327 2008/03/03 2008/03/03 17:30:00 2008/03/03 22:00:00 A
12 120033 2008/03/03 2008/03/03 17:30:00 2008/03/03 19:30:00 A
17 126690 2008/03/03 2008/03/03 16:45:00 2008/03/03 18:45:00 A
21 169241 2008/03/03 2008/03/03 17:30:00 2008/03/03 22:00:00 A
24 200716 2008/03/03 2008/03/03 17:30:00 2008/03/03 22:00:00 A
28 252836 2008/03/03 2008/03/03 17:30:00 2008/03/03 19:30:00 A
37 289039 2008/03/03 2008/03/03 16:30:00 2008/03/03 22:15:00 A
Problem with Query-2 Results:
Employee IDs 126690 & 289039 should not appear in the List.
Reason: Employee 126690: schedule start date & time is 2008/03/03 12:45:00 and falls outside
"16:30" and "17:45"
14 126690 2008/03/03 2008/03/03 18:45:00 2008/03/03 21:15:00 A
17 126690 2008/03/03 2008/03/03 16:45:00 2008/03/03 18:45:00 A
15 126690 2008/03/03 2008/03/03 12:45:00 2008/03/03 16:45:00 A
Reason: Employee 289039: schedule start date & time is 2008/03/03 13:45:00 and falls outside
37 289039 2008/03/03 2008/03/03 16:30:00 2008/03/03 22:15:00 A
39 289039 2008/03/03 2008/03/03 13:45:00 2008/03/03 16:30:00 AYour LEAD function is order by fw.start_dt_tm, in your first sql, the where clause limited the records return to REC_STAT = A and EMPL_ID = 289039.
In your 2nd query, there is no where clause, so to the LEAD function, the next record after seq 37 is seq 38 which has an end date of 2003-03-03 10:15 pm, not equal to the start time of record seq 37.
Message was edited by:
user477455 -
Help Required for Adobe Forms.....
Hello All,
I have a very unique requirement as such we have a form and in the "TO" string field where we specify the email address of the receivers, now we want to send address memo to multiple users, however in our search window we can search only one name at a time & need to open search window every time for every new user to be included in the address field. We need to have AJAX type of functionality such as AJAX does asynchronous calls to the back-end and get help values dynamically even when the user is entering help values.
In my case if I start typing S in the manager filed, an event should get triggered and return back the names of all managers who start with the letter S,
If we go to Google.com and start typing, as you type,e Google gets help values and displays them below the input field. This is based on making asynchronous calls to the back-end.
We want to send interactive adobe forms to the multiple users for their approval or information. while entering email ids of multiple users, we need to have functionality as described above.
I'll appreciate if anyone can help with some clear steps, document link or working code sample etc.
Regards,
Moderator message: sorry wrong forum, please have a look in the forum for "Adobe Interactive Forms".
Edited by: Thomas Zloch on May 25, 2011 10:49 AMDear Sunitha,
Thanks for your reply.
Can you please specify how to create a virtual table and Associated dataset in Adobe Forms.
Our scenario is to create a Sales Order in SAP via Adobe Forms through Offline.
Please find the below image.
Data for Company Code and Plant is available in 2 Internal Table.
Please assist in the following
How to combine these 2 Internal tables inside Adobe Forms.
Filter the values of Plant based on Company Code. -
Help required for temporary removing node 2 from the cluster
Hi Support,
There are some hardware issues on node 2 of 11g RAC cluster and vendor going to fix it;
We want to make node 2 not available until they fix it;
The user will continue with node 1 of the cluster;
Following are the current status of the site and I'm considering to perform the folowing task
while the folllowing command from node 1, i got the following output
D:\srvctl status database –d EPVAL
Instance epval1 is running on node corskmaps001
Instance epval2 is running on node corskmaps001
D:\srvctl status database –d EPPROD
Instance epprod1 is running on node corskmaps001
Instance epprod2 is running on node corskmaps001
I made the following steps in chorological order; I appreciate if someone can correct me if I made any mistake or add/amend/update as per requirement.
Assuming corskmaps002 is our passive mode which will be taken away by HP for hardware checking;
srvctl stop instance –d EPPROD -i EPPROD2
srvctl stop instance –d EPVAL -i EPVAL2
srvctl stop listerner_corskmaps002 –n corskmaps002
srvctl stop nodeapps -n corskmaps002
Do we require stopping service also once we stop the instance? Following are the commands if your answer is yes;
srvctl stop service -d EPROD -i EPPROD2
srvctl stop service -d EPVAL -i EPVAL2
srvctl disable service -d EPPROD -s EPPROD2
srvctl disable service -d EPVAL -s EPVAL2
I appreciate help
ThanksHi Bjoern,
I agree with you, very valid point, thanks for that;
Just for clarification, do you thing the sequence should be like this?
********disable command to start with***********
srvctl disable service -d EPPROD -s EPPROD2
srvctl disable service -d EPVAL -s EPVAL2
*********than instance stop commad**********
srvctl stop instance –d EPPROD -i EPPROD2
srvctl stop instance –d EPVAL -i EPVAL2
************than listener stopping command********
srvctl stop listerner_corskmaps002 –n corskmaps002
*************than node stopping command*********
srvctl stop nodeapps -n corskmaps002
*********do we also require stopping of the service ?>***************************
Do we require stopping service also once we stop the instance? Following are the commands if your answer is yes;
srvctl stop service -d EPROD -i EPPROD2
srvctl stop service -d EPVAL -i EPVAL2
Can you please eleborate further
Then, you also might want to add '-o transactional' or "transactional local" to the
instance stop command so that running transactions are not affected by this.
Thanks -
Urgent Help Required for Check Box in Table Column
Hi all,
Could any body help me to solve my problem?
First of all I have created a table whose one column is check box. The column of the tables are Name,Phone,ID,Address and a checkBox columns.In one view
the table will be found with data. I want to click on some of the rows(suppose there are 5 rows, but based on some condition I have selected the check box of 3 rows).
Next there will be a button(Supose SEND Button).
After selecting the check box I want to press that button and then a new window will come which will show two tables. one for selected rows(with the same columns name except check box) and another for Unchecked rows with the same column name(Name,Phone,ID,Address).
Could any body help me by sending the details and code?
Thanks and Regards.
SudipHi Sudip,
1) create custom controller and appropriate context structure there (dataNode(Name,Phone,ID,Address,Check))
2) create view StartView. Map data node from custom controller to node in view. Create table and bind context node attributes to appropriate table columns.
3) create view ResultView. Map data node from custom controller to node in view. Create 2 nodes (CheckedData, UncheckedData) with supply methods. Create filtering implementation in supply methods (add checked and unchecked node elements to appropriate nodes).
4) create new window with resultView as default view
4) in startView in button action handler put something like
IWDWindowInfo _windowInfo = wdComponentAPI.getComponentInfo().findInWindows("Popup");
IWDWindowManager manager = wdComponentAPI.getWindowManager();
IWDWindow _window = manager.createWindow(_windowInfo, true);
_window.open();
So, just tried localy and it works.
Best regards, Maksim Rashchynski. -
HELP.....with some home work
hey everyone.....i was wondering if any one can help me out......i am doing a project for school and need some help with my program......here is my program.....
....i am having trouble with trying to bring up the NameOfColleges array...i want to use the information that is in that array....in the main method.....i do not know how
to bring it from the fillStudent method to the main.....i bold the stuff that i need help with....thanks in advance......
import javax.swing.JOptionPane;
public class Student {
public java.util.Date getAcceptDate;
public static void main(String[] args) {
College[] student = new College[100];
int count = 0;
do {
student[count] = fillStudent();
count++;
} while(JOptionPane.showConfirmDialog(null, "Is there another student?") == JOptionPane.YES_OPTION);
*for(int i = 0; i < count; i++){*
* String output = "Date Aquired: " +student.todaysDate() + "\n\n" +*
* "Student Name: " + student[i].getName() + "\n" +*
* "Student GPA: " + student[i].getGPA();*
* for (int j = 0; j < NameOfColleges.length; j++){*
* String output2 = "College " + (j+1) + NameOfColleges[j] + "\n";*
private static College fillStudent() {
College one = new College();
String name, collegeName;
double GPA;
int numOFcoll;
name = JOptionPane.showInputDialog("Please enter the student's name:");
one.setName(name);
GPA = Double.parseDouble(JOptionPane.showInputDialog("Please enter " + name + "'s Grade Point Average: (example: 3.6"));
while (GPA <= 0.0 || GPA >= 4.0){
do{
GPA = Double.parseDouble(JOptionPane.showInputDialog("ERROR!! The number must be between 0.0 and 4.0. Please enter " + name + "'s Grade Point Average:"));
}while (GPA <= 0.0 || GPA >= 4.0);
one.setGPA(GPA);
numOFcoll = Integer.parseInt(JOptionPane.showInputDialog("Please enter the number of colleges that " + name + " applied to: (example: 3)"));
one.setNumofColl(numOFcoll);
String[] NameOfColleges = new String[numOFcoll];
for (int i = 0; i < NameOfColleges.length; i++){
collegeName = JOptionPane.showInputDialog("Please enter the name of college " + (i+1) +": ");
NameOfColleges[i] = collegeName;
for (int j = 0; j < NameOfColleges.length; j++){
if (JOptionPane.showConfirmDialog(null, "Did this student get accepted into " + NameOfColleges[j] +"?") == JOptionPane.YES_OPTION) {
one.setAccept(true);
} else
one.setAccept(false);
return one;dude dont mess up code like this. Think before you go for writing some code.
-
Help with Oracle Analytic Function scenario
Hi,
I am new to analytic functions and was wondering if someone could help me with the data scenario below. I have a table with the following data
COLUMN A COLUMN B COLUMN C
13368834 34323021 100
13368835 34438258 50
13368834 34438258 50
13368835 34323021 100
The output I want is
COLUMN A COLUMN B COLUMN C
13368834 34323021 100
13368835 34438258 50
A simple DISTINCT won't give me the desired output so i was wondering if there is any way that I can get the result using ANALYTIC FUNCTIONS and DISTINCT ..
Any help will be greatly appreciated.
Thanks.Hi,
Welcome to the forum!
Whenever you have a question, please post your sample data in a form that people can use to re-create the problem and test their solutions.
For example:
CREATE TABLE table_x
( columna NUMBER
, columnb NUMBER
, columnc NUMBER
INSERT INTO table_x (columna, columnb, columnc) VALUES (13368834, 34323021, 100);
INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34438258, 50);
INSERT INTO table_x (columna, columnb, columnc) VALUES (13368834, 34438258, 50);
INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34323021, 100);Do you want something that works in your version or Oracle? Of course you do! So tell us which version that is.
How do you get the results that you want? Explain what each row of output represents. It looks like
the 1st row contains the 1st distinct value from each column (where "first" means descending order for columnc, and ascending order for the others),
the 2nd row contains the 2nd distinct value,
the 3rd row contains the 3rd distinct value, and so on.
If that's what you want, here's one way to get it (in Oracle 9 and up):
WITH got_nums AS
SELECT columna, columnb, columnc
, DENSE_RANK () OVER (ORDER BY columna ) AS a_num
, DENSE_RANK () OVER (ORDER BY columnb ) AS b_num
, DENSE_RANK () OVER (ORDER BY columnc DESC) AS c_num
FROM table_x
SELECT MAX (a.columna) AS columna
, MAX (b.columnb) AS columnb
, MAX (c.columnc) AS columnc
FROM got_nums a
FULL OUTER JOIN got_nums b ON b.b_num = a.a_num
FULL OUTER JOIN got_nums c ON c.c_num = COALESCE (a.a_num, b.b_num)
GROUP BY COALESCE (a.a_num, b.b_num, c.c_num)
ORDER BY COALESCE (a.a_num, b.b_num, c.c_num)
;I've been trying to find a good name for this type of query. The best I've heard so far is "Prix Fixe Query", named after the menus where you get a choice of soups (listed in one column), appetizers (in another column), main dishes (in a 3rd column), and so on. The items on the first row don't necessaily have any relationship to each other.
The solution does not assume that there are the same number of distinct items in each column.
For example, if you add this row to the sample data:
INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34323021, 99);which is a copy of the last row, except that there is a completely new value for columnc, then the output is:
` COLUMNA COLUMNB COLUMNC
13368834 34323021 100
13368835 34438258 99
50starting in Oracle 11, you can also do this with an unpivot-pivot query. -
Help required for unicode compatibilty
Dear All,
We are in a process of analyzing the impact of unicode compatibility for our environment.
Following is our scenario:
- ECC6.0 is non unicode systsem
- Need to buid unicode CRM 7, SCM 7, PI 7.1 and BI7
- Need to integrate the above systems to non unicode ECC system.
Our questions are :
1. Is there any performance consideration when using communication between an Unicode and non-Unicode system?
Is Unicode - Unicode faster than Unicode - non-Unicode communication performance wise?
2. Do we face any technical or functinal problems while trying to integrate
unicode BI/ NW Java Stack to non unicode systems.
3. Do we need to review our sizing estimations due to unicode implemenation?
5. what will be the storage consumption increase for unicode systems compared to non unicode?
It would be greatly helpful for me if you can clarify these doubts.
Thanks and RegardsHi,
1. I think no one has really measured this. I expect a slightly higher requirement for Unicode <--> Non-Unicode interfaces.
2. Please have a look at SAP Notes 838402, 73606, 975768 and 1358929 for restrictions in Non-Unicode systems. SAP highly recommends to go for Unicode in the whole landscape.
3. and 5. If you use the SAP quicksizer (http://service.sap.com/quicksizing), then Unicode is integrated.
" Please note that the Quick Sizer results include Unicode requirements. For more
information on additional requirements caused by Unicode, see
http://service.sap.com/unicode -> Unicode Media Library -> Unicode information on
specific topics: SAP Business Suite Unicode Hardware Requirements"
Best regards,
Nils Buerckel
SAP AG -
Urgent Help Required for streaming video on Flash Media Server 3.5
Please follow the link for the detailed question. As im not getting any replies so that is why attaching a link
http://forums.adobe.com/thread/559567?tstart=0before running my application ( HelloWorld )
i always start FMS & FMAdministratorServer ( also checked in system services that they are running )
allow them in vista firewall
PLEASE LET ME KNOW
> is any problem with apache server ? how i figure out that it is running by FMS
> any port issues ?
package {
import flash.display.MovieClip;
import flash.net.Responder;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
public class HelloWorld extends MovieClip {
// Represents a network connection.
private var nc:NetConnection;
// Responder for call to server's serverHelloMsg -- see onReply() below.
private var myResponder:Responder = new Responder(onReply);
// Constructor.
public function HelloWorld() {
// Set display values.
textLbl.text = "";
connectBtn.label = "Connect";
// Register a listener for mouse clicks on the button.
connectBtn.addEventListener(MouseEvent.CLICK, connectHandler);
// When button is pressed, connect to or disconnect from the server.
public function connectHandler(event:MouseEvent):void {
if (connectBtn.label == "Connect") {
trace("Connecting...");
nc = new NetConnection();
// Connect to the server.
nc.connect("rtmp://localhost/HelloWorld");
// Call the server's client function serverHelloMsg, in HelloWorld.asc.
nc.call("serverHelloMsg", myResponder, "World");
connectBtn.label = "Disconnect";
} else {
trace("Disconnecting...");
// Close the connection.
nc.close();
connectBtn.label = "Connect";
textLbl.text = "";
// Responder function for nc.call() in connectHandler().
private function onReply(result:Object):void {
trace("onReply received value: " + result);
textLbl.text = String(result);
======================
HelloWorld.asc
application.onConnect = function( client ) {
client.serverHelloMsg = function( helloStr ) {
return "Hello, " + helloStr + "!";
application.acceptConnection( client ); -
Help required for farsi characterset
My client want to store data in English but for reporting they need some reports in Farsi(Persian) character.
How can i achieve this in database? Is i need to install two different database one for English & other one for Farsi(Import/Export purpose).
Kindly guide, i am doing this first time. For Farsi character which CHARACTER set i used.
I am using database 10.2.0.1.0 in Windows environment.
RegardsPl see this MOS Doc for the database characterset you need to use -
Does Oracle support the Farsi / Persian language (used in Iran, Afghanistan, Tajikistan, ....)? [ID 274108.1]
If you use the listed charactersets, the database will be able to store both English and Farsi content. It will be up to you (or some code) to provide the translations
HTH
Srini -
Seeburger help required for 810 and Dispatch Advice (IDOC type DESADV).
Hi All,
1. Please let me know blogs which clearly shows settings for Seeburger components for 850 (Purchase Order) to IDOC Scenario
--- Seeburger Workbench
--- Seeburger Mapping Designer (BIC)
--- Seeburger Counter and Varaibles
--- Seeburger AS2 Spoke
--- Any other Seeburger Component setting required
I have understand blog for 850 -- /people/rajeshkumar.pasupula/blog/2009/08/05/wanna-implement-seeburger-for-edi-find-the-booster
2. Anybody has blog for 810 or Dispatch Advice (IDOC type DESADV).
3. Can anybody provide me Mapping Logic (at field level) done in XI/PI for 850, 810 , Dispatch Advice (IDOC type DESADV) .
RegardsHi Rickkk,
1. Please let me know blogs which clearly shows settings for Seeburger components for 850 (Purchase Order) to IDOC Scenario
--- Seeburger Workbench
--- Seeburger Mapping Designer (BIC)
--- Seeburger Counter and Varaibles
--- Seeburger AS2 Spoke
--- Any other Seeburger Component setting required
For SEEBURGER workbench please go through this blog and navigate the enbebbed links furthur to know about Seeburger workbench too.
/people/prateek.srivastava3/blog/2009/08/01/seeburger--part-1--the-basics
2
2. Anybody has blog for 810 or Dispatch Advice (IDOC type DESADV).
For 810 i think the procedure would be the same but themseeburger mapping program that validates the ANSX 810 would be different.As far as 997is concerned 997 is a functional acknowledgement.Its a genric format that is used to send acknowledgement for any EDI transaction set that has been sent.
3. Can anybody provide me Mapping Logic (at field level) done in XI/PI for 850, 810 , Dispatch Advice (IDOC type DESADV) .
The logic will be based on the trading partner guidelines which will contain the description of all the semantic and syntactiic description about the segments ,its feilds.we need to consider the guidelines and target side specifications too while mapping.
Thanks,
Ram. -
Problem with SUM () analytic function
Dear all,
Please have a look at my problem.
SELECT CURR, DT, AMT, RATE,
SUM(AMT) OVER (PARTITION BY CURR ORDER BY DT) SUMOVER,
sum( amt * rate) over (PARTITION BY CURR ORDER BY DT) / SUM(AMT) OVER (PARTITION BY CURR ORDER BY DT) avgrt
FROM
select 'CHF' CURR, ADD_MONTHS(TO_DATE('01-DEC-07'), LEVEL -1) DT, 100 * LEVEL AMT, 1 + ( 5* LEVEL/100) RATE
FROM DUAL CONNECT BY LEVEL < 10
SQL> /
CUR DT AMT RATE SUMOVER AVGRT
CHF 01-DEC-07 100 1.05 100 1.05
CHF 01-JAN-08 200 1.1 300 1.08333333
CHF 01-FEB-08 300 1.15 600 1.11666667
CHF 01-MAR-08 400 1.2 1000 1.15
CHF 01-APR-08 500 1.25 1500 1.18333333
CHF 01-MAY-08 600 1.3 2100 1.21666667
CHF 01-JUN-08 700 1.35 2800 1.25
CHF 01-JUL-08 800 1.4 3600 1.28333333
CHF 01-AUG-08 900 1.45 4500 1.31666667
Table Revaluation
select 'CHF' CURR1, '31-DEC-07' DT , 1.08 RATE FROM DUAL UNION ALL
select 'CHF' CURR1, '31-MAR-08' DT , 1.22 RATE FROM DUAL UNION ALL
select 'CHF' CURR1, '30-JUN-08' DT , 1.38 RATE FROM DUAL
CUR DT RATE
CHF 31-DEC-07 1.08
CHF 31-MAR-08 1.22
CHF 30-JUN-08 1.38.
Problem is with the calculation of average rate.
I want to consider the data in the revaluation table to be used in the calculation of
average rate.
So average rate for Jan-08 will be
(100 * 1.08(dec revaluation rate) + 200 * 1.1 ) / (300) = 1.093333333
for Feb-08
(100 * 1.08(dec revaluation rate) + 200 * 1.1 + 300 * 1.15) / (600) = 1.121666667
for mar-08
(100 * 1.08(dec revaluation rate) + 200 * 1.1 + 300 * 1.15 + 400 * 1.2) / (1000) = 1.153
for Apr-08
(1000 * 1.22(Apr revaluation rate) + 500 * 1.25) /1500 = 1.23
for May-08
(1000 * 1.22(Apr revaluation rate) + 500 * 1.25 + 600 * 1.30 ) /2100 = 1.25
and so on..
Kindly adviceHi,
The main thing in this problem is that for every dt you want to compute the cumulative total from previous rows using the formula
SUM (amt * rate)
But rate can be either the rate from the revaluation table or the rate from the main table. For evaluating prior dates, you wnat to use the most recent rate.
I'm not sure if you can do this using analytic functions. Like Damorgan said, you should use a self-join.
The query below gives you the results you requested:
WITH
revaluation AS
SELECT 'CHF' curr1, TO_DATE ('31-DEC-07', 'DD-MON-RR') dt, 1.08 rate FROM dual UNION ALL
SELECT 'CHF' curr1, TO_DATE ('31-MAR-08', 'DD-MON-RR') dt, 1.22 rate FROM dual UNION ALL
SELECT 'CHF' curr1, TO_DATE ('30-JUN-08', 'DD-MON-RR') dt, 1.38 rate FROM dual
original_data AS
select 'CHF' curr
, ADD_MONTHS(TO_DATE('01-DEC-07'), LEVEL -1) dt
, 100 * LEVEL amt
, 1 + ( 5* LEVEL/100) rate
FROM dual
CONNECT BY LEVEL < 10
two_rates AS
SELECT od.*
SELECT MAX (dt)
FROM revaluation
WHERE curr1 = od.curr
AND dt <= od.dt
) AS r_dt
SELECT AVG (rate) KEEP (DENSE_RANK LAST ORDER BY dt)
FROM revaluation
WHERE curr1 = od.curr
AND dt <= od.dt
) AS r_rate
FROM original_data od
SELECT c.curr
, c.dt
, c.amt
, c.rate
, SUM (p.amt) AS sumover
, SUM ( p.amt
* CASE
WHEN p.dt <= c.r_dt
THEN c.r_rate
ELSE p.rate
END
/ SUM (p.amt) AS avgrt
FROM two_rates c
JOIN original_data p ON c.curr = p.curr
AND c.dt >= p.dt
GROUP BY c.curr, c.dt, c.amt, c.rate
ORDER BY c.curr, c.dt
;
Maybe you are looking for
-
CS4 Installation on Windows 8.1 Setup error
So, after getting quite quite annoyed at this, I am asking the question: How do i fix the "Setup has encountered an error and cannot continue" error on installation with windows 8.1 Details of things i have tried and know So, New install of Windows 8
-
Optional attributes in XML to ABAP transformation
Hi, I have to deserialize (transformation xml to abap) an xml input file. I want to use SAP ST (Simple Transformations). This xml format is using attributes Such attributes can be transformed in ST with <tt:attribute name="item_id" value-ref="MATNR"/
-
SQL challenge: avoid this self-join!!!
Here's something of a challenging SQL problem. I'm trying to persist an arbitrary number of attributes for an object. I am trying to do this in a regular relational table both for performance and to make future upgrades easier. The problem is that I
-
Major problems after ICS on my Bionic
So I've had the Bionic since it was released and have never had any major problems with it. It wasn't until a few days ago when I woke up to a notice of the ICS update finally being available, so of course I pressed on Install now. I ended up going
-
Please Cancell my 2 orders in 4 days
Hi Please cancel two orders from my skype account actually i subscribed a month subscription while i was traveelling other place now i am back and dont want any subscriptions ..Please find the order Deatils below Order 1Skype Name: manozorama Produc