Sql lead and lag / other option for conditional use
Hi all gurus of SQL
I want to pull previous record and subtract status_date from both the record to find the # number of days.
Create table temp (o_id number , r_id number ,status_date date , status varchar2(30));
Sample data
i_id r_id status_date status
33493 308963 16-MAR-12 Incarcerated
33493 308943 26-SEP-11 City/County Jail
33493 306529 15-DEC-09 Active
33493 295327 25-SEP-09 City/County Jail
33493 293630 30-JUL-09 Active
33493 292828 30-JUL-09 Active
33493 292830 30-JUL-09 Active
33493 292826 21-MAY-09 City/County Jail
33493 291854 05-MAY-09 Active
Select I_ID, status_date, lag (R_ID, 1) over (order by status_date )
from TEMP where I_IDin (33493) and status_date >='01-NOV-2007
and temp.status='Active';
Logic I am trying to accomplish is find the incarceration status_date and then find the latest active , status_date and subtract those dates.
for example 16-mar-12 minus 15-DEC-09
Thanks for help..
Pls help me brainstorm this..
Hi,
This definetly sounds like a job for analytic functions, but LAG might not be the best choice if you can have multiple 'Incarcerated' rows. You might be better of with LAST_VALUE or MAX, like this:
WITH got_prev_active_status_date AS
SELECT temp.* -- or list whatever columns you need
, MAX ( CASE
WHEN status = 'Active'
THEN status_date
END
) OVER ( PARTITION BY i_id -- Just guessing
ORDER BY status_date
) AS prev_active_status_date
FROM temp
WHERE status IN ('Active', 'Incarcerated')
SELECT p.* -- or list whatever columns you need
, status_date - prev_active_status_date AS days_active
FROM got_prev_active_status_date
WHERE status = 'Incarcerated';
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Point out where the query above is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
If you modify the query at all, post your modified version.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Similar Messages
-
Hello,
The resource filled his/her timesheet in PWA.
Now :
What are the differences between Turn in Final Timesheet
and the other option: Send Progress for Selected Tasks?
ThanksYou are partially correct and partially wrong.
Turn
in Final Timesheet sends
the timesheet to the Timesheet Manager for Approval
but task update always goes to Status manger of the task. Taks manager you can see in MPP(insert status manager field then check)
Yes
after approval progress will be available in MPP as well as in Projectweb app as % complete .
Send
Progress for Selected Tasks
Send progress of selected task to status manager after approval update will be available in both MPP and Projectweb
app as % complete.
In Send
Progress for Selected Tasks Timesheet
Manager doesn't receive anything in his Approval center
because all the update directly go to Status manager Approval center.
Here you have to understand
that there are two role Timesheet Manager(for timesheet approval) and Status manager(for task
actual approval)
kirtesh -
Are there other options for renting and downloading movies?
I have watched movies downloaded from Apple a couple of time, but I really don't like the iTunes interface - my main complaint is that there is no way to filter movies so that I can quickly scan for rentals.
I rarely watch any movie more than one time, so I have no interest in buying a movie - I only want to rent, and it is a huge waste of time to hunt through iTunes movies one by one to see if I can rent it or not. It just not worth my time.
I don't know if Apple plans to fix this shortcoming or not, but until then, are there other options for downloading rental movies to watch on my MacBook Pro or my iPad? Online streaming is fine, and I use Netflix and others for that, but I would like to get movies to watch on airplanes and other places where I don't have an internet connection.
ThanksTry NFS. SMB is for connecting to Windows servers.
-
I have just created an Apple Id for itunes, it is allowing me to get to the debit card stage but they no longer accept Visa Debit, there is no other option for me as i dont have any other cards and there isnt a 'none' option! HELP!!
How did you create the account ? Unless you followed the instructions on the page that you post from exactly then you won't get the 'none' option and you will need to enter payment details - those instructions won't work on existing accounts.
I tried those instructions a week ago in response to another thread and I got the 'none' option on it e.g. on my computer's iTunes I logged out of my existing account, found a free app in the store, clicked on its 'free' price, clicked on 'create Apple id' on the popup, and after agreeing to the terms and filling in my details I was able to select 'none' as my payment option and download a free app with it. -
How do I Identify Lead and Lag in consecutive dates with multiple values?
I am using:
Oracle SQL Developer (3.0.04)
Build MAin-04.34
Oracle Database 11g
Enterprise Edition 11.2.0.1.0 - 64bit Production
I would like to identify the Lead and Lags based on two groups.
The groupping is that multiple C_ID can be found in a Single W_ID
and that multiple D_VAL can be found in C_ID
So I would like to identify and mark with "Lead" and "Lag" related to the "consecutivedaysc" (this already matches the D_VAL and C_ID very well) for example W_ID 2004 has C_ID 2059 with D_VAL of 44 for April 2 & 3, the consecutive days are 2 and I would like to correctly mark April 2 as the Lead and April 3 as the lag.
Then I would like to mark the "Lead" and "Lag" independent of if there are multiple D_VAL on the same W_ID
Example that I am having trouble with:
W_ID 2285 on April 10 for C_ID 7847, I don't understand whay I can't get "Lag" in stead of a "Lead" realted to the consecutivedaysw
I would like to eventually have it that the data gets summarized based on W_ID and sinlge (non-repeating) dt with Lead and Lags.
table
with t as (
select 4592 U_KEY,0 D_VAL_PRESENT,2004 W_ID,to_date('4/1/2013','mm-dd-yyyy') dt,2059 C_ID, (null) D_VAL,0 GWID,13 GCID,1 CONSECUTIVEDAYSC,1 CONSECUTIVEDAYSW from dual union all
select 4591,1,2004,to_date('4/2/2013','mm-dd-yyyy'),2059,44,1,11,2,13 from dual union all
select 4590,1,2004,to_date('4/3/2013','mm-dd-yyyy'),2059,44,1,11,2,13 from dual union all
select 4589,1,2004,to_date('4/4/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4588,1,2004,to_date('4/5/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4587,1,2004,to_date('4/6/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4586,1,2004,to_date('4/7/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4585,1,2004,to_date('4/8/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4584,1,2004,to_date('4/9/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4583,1,2004,to_date('4/10/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4582,1,2004,to_date('4/11/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4581,1,2004,to_date('4/12/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4580,1,2004,to_date('4/13/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 4579,1,2004,to_date('4/14/2013','mm-dd-yyyy'),2059,389,1,0,11,13 from dual union all
select 1092,0,2686,to_date('4/1/2013','mm-dd-yyyy'),7210,(null),0,11,3,3 from dual union all
select 3416,0,2686,to_date('4/1/2013','mm-dd-yyyy'),7211,(null),0,11,3,3 from dual union all
select 18118,0,2686,to_date('4/1/2013','mm-dd-yyyy'),17391,(null),0,11,3,3 from dual union all
select 1091,0,2686,to_date('4/2/2013','mm-dd-yyyy'),7210,(null),0,11,3,3 from dual union all
select 3415,0,2686,to_date('4/2/2013','mm-dd-yyyy'),7211,(null),0,11,3,3 from dual union all
select 18117,0,2686,to_date('4/2/2013','mm-dd-yyyy'),17391,(null),0,11,3,3 from dual union all
select 1090,0,2686,to_date('4/3/2013','mm-dd-yyyy'),7210,(null),0,11,3,3 from dual union all
select 3414,0,2686,to_date('4/3/2013','mm-dd-yyyy'),7211,(null),0,11,3,3 from dual union all
select 18116,0,2686,to_date('4/3/2013','mm-dd-yyyy'),17391,(null),0,11,3,3 from dual union all
select 1089,1,2686,to_date('4/4/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3413,1,2686,to_date('4/4/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18115,1,2686,to_date('4/4/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1088,1,2686,to_date('4/5/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3412,1,2686,to_date('4/5/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18114,1,2686,to_date('4/5/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1087,1,2686,to_date('4/6/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3411,1,2686,to_date('4/6/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18113,1,2686,to_date('4/6/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1086,1,2686,to_date('4/7/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3410,1,2686,to_date('4/7/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18112,1,2686,to_date('4/7/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1085,1,2686,to_date('4/8/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3409,1,2686,to_date('4/8/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18111,1,2686,to_date('4/8/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1084,1,2686,to_date('4/9/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3408,1,2686,to_date('4/9/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18110,1,2686,to_date('4/9/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1083,1,2686,to_date('4/10/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3407,1,2686,to_date('4/10/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18109,1,2686,to_date('4/10/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1082,1,2686,to_date('4/11/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3406,1,2686,to_date('4/11/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18108,1,2686,to_date('4/11/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1081,1,2686,to_date('4/12/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3405,1,2686,to_date('4/12/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18107,1,2686,to_date('4/12/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1080,1,2686,to_date('4/13/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3404,1,2686,to_date('4/13/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18106,1,2686,to_date('4/13/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 1079,1,2686,to_date('4/14/2013','mm-dd-yyyy'),7210,51,9,0,11,11 from dual union all
select 3403,1,2686,to_date('4/14/2013','mm-dd-yyyy'),7211,51,9,0,11,11 from dual union all
select 18105,1,2686,to_date('4/14/2013','mm-dd-yyyy'),17391,51,9,0,11,11 from dual union all
select 17390,1,3034,to_date('4/1/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 17389,1,3034,to_date('4/2/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 17388,1,3034,to_date('4/3/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 17387,1,3034,to_date('4/4/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 17386,1,3034,to_date('4/5/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 7305,1,3034,to_date('4/6/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17385,1,3034,to_date('4/6/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14123,1,3034,to_date('4/6/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 17384,1,3034,to_date('4/7/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 17383,1,3034,to_date('4/8/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 7302,1,3034,to_date('4/9/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17382,1,3034,to_date('4/9/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14120,1,3034,to_date('4/9/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 7301,1,3034,to_date('4/10/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17381,1,3034,to_date('4/10/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14119,1,3034,to_date('4/10/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 7300,1,3034,to_date('4/11/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17380,1,3034,to_date('4/11/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14118,1,3034,to_date('4/11/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 7299,1,3034,to_date('4/12/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17379,1,3034,to_date('4/12/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14117,1,3034,to_date('4/12/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 7298,1,3034,to_date('4/13/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17378,1,3034,to_date('4/13/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14116,1,3034,to_date('4/13/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual union all
select 7297,1,3034,to_date('4/14/2013','mm-dd-yyyy'),5394,44,0,0,7,14 from dual union all
select 17377,1,3034,to_date('4/14/2013','mm-dd-yyyy'),5395,298,0,0,14,14 from dual union all
select 14115,1,3034,to_date('4/14/2013','mm-dd-yyyy'),22421,44,0,0,7,14 from dual
)the script that I am using:
select
t.*/
case
when lag(dt) over(partition by c_id, d_val order by dt, u_key)+1 = dt
then'Lag'
when lead(dt) over(partition by c_id, d_val order by dt, u_key)-1 = dt
then 'Lead_1'
when consecutivedaysc = 1
then'Lead_3'
else 'wrong'
end LeadLagD_VAL,
case
when lag(dt) over(partition by w_id, c_id, d_val_present,gwid order by dt)+1 = dt
then'Lag'
when lead(dt) over(partition by w_id, c_id, d_val_present, gwid order by dt)-1 = dt
then 'Lead_A'
when consecutivedaysw = 1
then 'Lead_B'
else 'wrong'
end Lead_Lag2
from t
order by
W_ID,
dt asc,
C_ID asc
;the results should look like this (but haveing issues)
u_key D_VAL_PRESENT W_ID C_ID DT D_VAL GWID GCID CONSECUTIVEDAYSC CONSECUTIVEDAYSW LEADLAGD_VAL LEAD_LAG2
4592 0 2004 2059 01-APR-13 0 13 1 1 Lead_1 Lead_A
4591 1 2004 2059 02-APR-13 44 1 11 2 13 Lead_1 Lead_A
4590 1 2004 2059 03-APR-13 44 1 11 2 13 Lag Lag
4589 1 2004 2059 04-APR-13 389 1 0 11 13 Lead_1 Lag
4588 1 2004 2059 05-APR-13 389 1 0 11 13 Lag Lag
4587 1 2004 2059 06-APR-13 389 1 0 11 13 Lag Lag
4586 1 2004 2059 07-APR-13 389 1 0 11 13 Lag Lag
4585 1 2004 2059 08-APR-13 389 1 0 11 13 Lag Lag
4584 1 2004 2059 09-APR-13 389 1 0 11 13 Lag Lag
4583 1 2004 2059 10-APR-13 389 1 0 11 13 Lag Lag
4582 1 2004 2059 11-APR-13 389 1 0 11 13 Lag Lag
4581 1 2004 2059 12-APR-13 389 1 0 11 13 Lag Lag
4580 1 2004 2059 13-APR-13 389 1 0 11 13 Lag Lag
4579 1 2004 2059 14-APR-13 389 1 0 11 13 Lag Lag
1092 0 2686 7210 01-APR-13 0 11 3 3 Lead_1 Lead_A
3416 0 2686 7211 01-APR-13 0 11 3 3 Lead_1 Lead_A
18118 0 2686 17391 01-APR-13 0 11 3 3 Lead_1 Lead_A
1091 0 2686 7210 02-APR-13 0 11 3 3 Lag Lag
3415 0 2686 7211 02-APR-13 0 11 3 3 Lag Lag
18117 0 2686 17391 02-APR-13 0 11 3 3 Lag Lag
1090 0 2686 7210 03-APR-13 0 11 3 3 Lag Lag
3414 0 2686 7211 03-APR-13 0 11 3 3 Lag Lag
18116 0 2686 17391 03-APR-13 0 11 3 3 Lag Lag
1089 1 2686 7210 04-APR-13 51 9 0 11 11 Lead_1 Lead_A
3413 1 2686 7211 04-APR-13 51 9 0 11 11 Lead_1 Lead_A
18115 1 2686 17391 04-APR-13 51 9 0 11 11 Lead_1 Lead_A
1088 1 2686 7210 05-APR-13 51 9 0 11 11 Lag Lag
3412 1 2686 7211 05-APR-13 51 9 0 11 11 Lag Lag
18114 1 2686 17391 05-APR-13 51 9 0 11 11 Lag Lag
1087 1 2686 7210 06-APR-13 51 9 0 11 11 Lag Lag
3411 1 2686 7211 06-APR-13 51 9 0 11 11 Lag Lag
18113 1 2686 17391 06-APR-13 51 9 0 11 11 Lag Lag
1086 1 2686 7210 07-APR-13 51 9 0 11 11 Lag Lag
3410 1 2686 7211 07-APR-13 51 9 0 11 11 Lag Lag
18112 1 2686 17391 07-APR-13 51 9 0 11 11 Lag Lag
1085 1 2686 7210 08-APR-13 51 9 0 11 11 Lag Lag
3409 1 2686 7211 08-APR-13 51 9 0 11 11 Lag Lag
18111 1 2686 17391 08-APR-13 51 9 0 11 11 Lag Lag
1084 1 2686 7210 09-APR-13 51 9 0 11 11 Lag Lag
3408 1 2686 7211 09-APR-13 51 9 0 11 11 Lag Lag
18110 1 2686 17391 09-APR-13 51 9 0 11 11 Lag Lag
1083 1 2686 7210 10-APR-13 51 9 0 11 11 Lag Lag
3407 1 2686 7211 10-APR-13 51 9 0 11 11 Lag Lag
18109 1 2686 17391 10-APR-13 51 9 0 11 11 Lag Lag
1082 1 2686 7210 11-APR-13 51 9 0 11 11 Lag Lag
3406 1 2686 7211 11-APR-13 51 9 0 11 11 Lag Lag
18108 1 2686 17391 11-APR-13 51 9 0 11 11 Lag Lag
1081 1 2686 7210 12-APR-13 51 9 0 11 11 Lag Lag
3405 1 2686 7211 12-APR-13 51 9 0 11 11 Lag Lag
18107 1 2686 17391 12-APR-13 51 9 0 11 11 Lag Lag
1080 1 2686 7210 13-APR-13 51 9 0 11 11 Lag Lag
3404 1 2686 7211 13-APR-13 51 9 0 11 11 Lag Lag
18106 1 2686 17391 13-APR-13 51 9 0 11 11 Lag Lag
1079 1 2686 7210 14-APR-13 51 9 0 11 11 Lag Lag
3403 1 2686 7211 14-APR-13 51 9 0 11 11 Lag Lag
18105 1 2686 17391 14-APR-13 51 9 0 11 11 Lag Lag
17390 1 3034 5395 01-APR-13 298 0 0 14 14 Lead_1 Lead_A
17389 1 3034 5395 02-APR-13 298 0 0 14 14 Lag Lag
17388 1 3034 5395 03-APR-13 298 0 0 14 14 Lag Lag
17387 1 3034 5395 04-APR-13 298 0 0 14 14 Lag Lag
17386 1 3034 5395 05-APR-13 298 0 0 14 14 Lag Lag
7305 1 3034 5394 06-APR-13 44 0 0 7 14 Lead_1 Lag
17385 1 3034 5395 06-APR-13 298 0 0 14 14 Lag Lag
14123 1 3034 22421 06-APR-13 44 0 0 7 14 Lead_1 Lag
17384 1 3034 5395 07-APR-13 298 0 0 14 14 Lag Lag
17383 1 3034 5395 08-APR-13 298 0 0 14 14 Lag Lag
7302 1 3034 5394 09-APR-13 44 0 0 7 14 Lead_1 Lag
17382 1 3034 5395 09-APR-13 298 0 0 14 14 Lag Lag
14120 1 3034 22421 09-APR-13 44 0 0 7 14 Lead_1 Lag
7301 1 3034 5394 10-APR-13 44 0 0 7 14 Lag Lag
17381 1 3034 5395 10-APR-13 298 0 0 14 14 Lag Lag
14119 1 3034 22421 10-APR-13 44 0 0 7 14 Lag Lag
7300 1 3034 5394 11-APR-13 44 0 0 7 14 Lag Lag
17380 1 3034 5395 11-APR-13 298 0 0 14 14 Lag Lag
14118 1 3034 22421 11-APR-13 44 0 0 7 14 Lag Lag
7299 1 3034 5394 12-APR-13 44 0 0 7 14 Lag Lag
17379 1 3034 5395 12-APR-13 298 0 0 14 14 Lag Lag
14117 1 3034 22421 12-APR-13 44 0 0 7 14 Lag Lag
7298 1 3034 5394 13-APR-13 44 0 0 7 14 Lag Lag
17378 1 3034 5395 13-APR-13 298 0 0 14 14 Lag Lag
14116 1 3034 22421 13-APR-13 44 0 0 7 14 Lag Lag
7297 1 3034 5394 14-APR-13 44 0 0 7 14 Lag Lag
17377 1 3034 5395 14-APR-13 298 0 0 14 14 Lag Lag
14115 1 3034 22421 14-APR-13 44 0 0 7 14 Lag Lag I place the "wrong" showing that neither the when conditions were no able to work.
any suggestions on a better direction for me to solve this?
Edited by: 1004407 on May 23, 2013 1:16 PM
Then I am trying to get this, not to include C_ID
u_key D_VAL_PRESENT W_ID DT CONSECUTIVEDAYSW LEAD_LAG2
4592 0 2004 01-APR-13 1 Lead_A
4591 1 2004 02-APR-13 13 Lead_A
4590 1 2004 03-APR-13 13 Lag
4589 1 2004 04-APR-13 13 Lag
4588 1 2004 05-APR-13 13 Lag
4587 1 2004 06-APR-13 13 Lag
4586 1 2004 07-APR-13 13 Lag
4585 1 2004 08-APR-13 13 Lag
4584 1 2004 09-APR-13 13 Lag
4583 1 2004 10-APR-13 13 Lag
4582 1 2004 11-APR-13 13 Lag
4581 1 2004 12-APR-13 13 Lag
4580 1 2004 13-APR-13 13 Lag
4579 1 2004 14-APR-13 13 Lag
1092 0 2686 01-APR-13 3 Lead_A
1091 0 2686 02-APR-13 3 Lag
1090 0 2686 03-APR-13 3 Lag
1089 1 2686 04-APR-13 11 Lead_A
1088 1 2686 05-APR-13 11 Lag
1087 1 2686 06-APR-13 11 Lag
1086 1 2686 07-APR-13 11 Lag
1085 1 2686 08-APR-13 11 Lag
1084 1 2686 09-APR-13 11 Lag
1083 1 2686 10-APR-13 11 Lag
1082 1 2686 11-APR-13 11 Lag
1081 1 2686 12-APR-13 11 Lag
1080 1 2686 13-APR-13 11 Lag
1079 1 2686 14-APR-13 11 Lag
17390 1 3034 01-APR-13 14 Lead_A
17389 1 3034 02-APR-13 14 Lag
17388 1 3034 03-APR-13 14 Lag
17387 1 3034 04-APR-13 14 Lag
17386 1 3034 05-APR-13 14 Lag
7305 1 3034 06-APR-13 14 Lag
17384 1 3034 07-APR-13 14 Lag
17383 1 3034 08-APR-13 14 Lag
7302 1 3034 09-APR-13 14 Lag
7301 1 3034 10-APR-13 14 Lag
7300 1 3034 11-APR-13 14 Lag
7299 1 3034 12-APR-13 14 Lag
7298 1 3034 13-APR-13 14 Lag
7297 1 3034 14-APR-13 14 Lag then into this (which I would use where Lead_Lag2 = "Lead_A"
u_key D_VAL_PRESENT W_ID DT CONSECUTIVEDAYSW LEAD_LAG2
4592 0 2004 01-APR-13 1 Lead_A
4591 1 2004 02-APR-13 13 Lead_A
1092 0 2686 01-APR-13 3 Lead_A
11089 1 2686 04-APR-13 11 Lead_A
17390 1 3034 01-APR-13 14 Lead_A but onething at a time.
Thanks for point out the errors Frank, always helpful to know what others see.
Edited by: 1004407 on May 23, 2013 2:36 PM
Edited by: 1004407 on May 23, 2013 4:01 PMIs this the first set you expect?
SQL> with flagged as
2 (
3 select w_id,d_val,dt,u_key,
4 case when lag(dt) over(partition by w_id,d_val order by dt,u_key)
5 in (dt,dt-1)
6 then 0
7 else 1
8 end flg
9 from t
10 ),
11 summed as
12 (
13 select w_id,d_val,dt,u_key,
14 sum(flg) over(order by w_id,d_val nulls first,dt,u_key) sm
15 from flagged
16 ),
17 day_count as
18 (
19 select w_id,d_val,dt,u_key,count(distinct dt) over(partition by sm) cnt
20 from summed
21 )
22 select w_id,d_val,dt,u_key,cnt
23 from day_count
24 order by w_id,d_val nulls first,dt,u_key;
W_ID D_VAL DT U_KEY CNT
2004 01-APR-13 4592 1
2004 44 02-APR-13 4591 2
2004 44 03-APR-13 4590 2
2004 389 04-APR-13 4589 11
2004 389 05-APR-13 4588 11
2004 389 06-APR-13 4587 11
2004 389 07-APR-13 4586 11
2004 389 08-APR-13 4585 11
2004 389 09-APR-13 4584 11
2004 389 10-APR-13 4583 11
2004 389 11-APR-13 4582 11
2004 389 12-APR-13 4581 11
2004 389 13-APR-13 4580 11
2004 389 14-APR-13 4579 11
2686 01-APR-13 1092 3
2686 01-APR-13 3416 3
2686 01-APR-13 18118 3
2686 02-APR-13 1091 3
2686 02-APR-13 3415 3
2686 02-APR-13 18117 3
2686 03-APR-13 1090 3
2686 03-APR-13 3414 3
2686 03-APR-13 18116 3
..... -
Missing "Add Records" and "Refresh Records" options for data sets post domain re-import
We recently had to re-install the Endeca server and as part of which had to export and re-import the data domains. Everything went fine except for the fact that newly re-imported data sets showcase just the "Manage Attributes" and the "Delete Data Set" options for an administrator login in. The previously available options to "Add Records" and "Refresh Records" beyond manage attributes/Delete Data Set are missing.
Thoughts? Is there a security setting to enable these?So are you talking about the Add Records and Reload Records options for a data set in Studio?
There are no separate security settings for these options. If a user is an application administrator (is able to edit the application), then they should have access to these options.
The options are only available for data domains created using the Provisioning Service (created by uploading a file or from the JDBC or BI Server data source from the Data Source Library).
I don't know if the process of exporting and re-importing the data domains (not sure how you did that) could somehow cause the data sets to no longer know that they were created by the Provisioning Service, in which case those options would not be enabled. -
'use dynamic name' and 'caching properites' options for alias table...
Hello everybody,
can anybody please explain 'use dynamic name' and 'caching properites' options for alias tables...
Thanks...
eagerly waiting for a response..
VijayYou want to create dynamic target table name right?
You can refresh a variable like #GET_SESSION
#GET_SESSION= SELECT <%=odiRef.getSession("SESS_NAME")%> FROM DUAL
My tmp table name like TMP_#GET_SESSION
then in your package refresh #GET_SESSION variable and you can use it.
I hope this can be helpful
Thanks -
I'm running iTunes 10.7.0.21 on a Windows 7 PC. Every time I select iTunes Store, or Home or Search from the Store menu or select iTunes Help or iTunes Tutorial or Keyboard Shortcuts from the Help menu (and probably other options) iTunes crashes (error = "iTunes has stopped working"). I tried doing a repair if iTunes from Programs and Features, but it didn't help.
Hello cee3
Continue your troubleshooting with the article below. It will walk you through starting up in Safe Mode to see if that sorts it out. If it does not, you may need to remove iTunes and its associating software and then reinstall iTunes.
iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
http://support.apple.com/kb/TS1717
Regards,
-Norm G. -
Other option for SubQuery...
Hi All
I want to Use other option for Subquery for Performance Tunning. Any Other way for this?
Thanx in Advance< i don't want to Join >
You don't want to use subqueries, and you don't want to join. That limits your options as inline views and subquery factoring are both variants on subqueries.
You can go farther afield and look at the set operators which can sometimes simulate joins and subqueries but don't usually help performance, or write inline/pipelined functions as alternate ways to get the data but these are all but guranteed to decrease performance and involve a lot of extra work besides. -
I am unable to buy any of applications on App Store as it is not accepting any of cards and doesnot show option for credit card.
ThanksTry this to change your payment method: http://support.apple.com/kb/PH12507
-
Recently downloaded FLAC app. and want to stream 96/24 to my stereo system. Whats best wireless and hard wired option for a 30 foot run?
Try these 3 possible solutions:
1. Restart iPad
Hold down the Sleep/Wake button until the red slider appears. Slide your finger across the slider to turn off iPad. To turn iPad back on, hold down the Sleep/Wake until the Apple logo appears.
2. Close inactive Apps
Double-click the Home button; hold Apps down (in the Task Bar) for a second or two until you see the minus sign. Tap and close all inactive Apps.
3. Reset iPad
Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Ignore the red slider. -
Other options for emailed itunes gift card?
I received an itunes gift card via email. Unlike a physical gift card, it does not have a redemption code. Just a 'redeem' button.
I don't want to redeem this code. I would like to gift it to someone else or perhaps sell it. But I need a physical card with a redemption code.
Apple says my only choice is to redeem it to my itunes account. I didn't want to ask the purchaser to request a refund.
Are there any other options for this gift card email? thanks!thank you for your reply. i know you could stream in between computers. i guess i just want one device to do everything and i am torn as to whether or not to buy the basestation. i guess the odds of a newer one coming out with the music feauture in the next few months is probably way beyond slim to none!
-
if we dont want to use sleep/wakeup button for dissconnect the call so there is any other option for dissconnect the call without using sleep/wakeup button in ios 8.1.3 . kindly suggest..!
Hello kumar kalptaru,
Thank you for participating in the Apple Support Communities.
It sounds like you're wondering how to hang up a call besides using the Sleep/Wake button.
Other than this, you can tap the red hang up button on the Phone app. See the iPhone User Guide for more help:
While on a call - iPhone
End a call. Tap or press the Sleep/Wake button.
Best Regards,
Jeremy -
My first i device was an iPod touch that I was given for use in my classroom. Then I got an iPhone for personal use. Both items are listed under the same username and account. Since then I now have 2 iPads, one for home and one for work. I have many apps that are only for work like Math Zombie and Science Facts, and many that are for personal use, like Facebook and YouVersion. I know that I can synch each device and tell iTunes which apps go on which device. However at home I use a Mac, and my school computer is a PC. I am wondering if I should split my account and keep personal separate from work. Then I can synch all school related devices on the PC and home devices on the Mac. I realize that there maybe the rare occaision that I might want one app for both accounts. That's the chance I take on splitting my account. Are there ay benefits one way or the other?
Will you be the person paying for apps on both accounts?
Are you the only person that will use both of the iPads?
Is there a chance students will be using the work iPad and if so, do you want personal data stored on it?
If you're the only one using it I'd keep the same account just to have the flexibility of having access to everything on all devices. If your students will be using it or if the school is paying for the school apps I'd keep separate accounts. It all depends on how often you will use school apps from home, and home apps at school. Just some things to consider... -
Can I create a fillable pdf form and then export it for client use on my web site?
Can I create a fillable pdf form and then export it for client use on my web site? I need clients to be able to fill in the (registration) form on my site then submit it via email.
[discussion moved to Creating, Editing & Exporting PDFs forum]
Maybe you are looking for
-
Contacts app is not on my newly purchased 4s iPhone home screen. Why? And please how do I resolve this? Thanks in anticipation!
-
Column int_objname empty after register schema
Hi all, We have come across a very strange feature in our XDB repository (RDBMS 10.2.0.2 EE) and I hope someone can give a hint to solve it. In the past we registered xml schemas and worked with it with success. The schemas are local. Now, we're impl
-
Where can I download a trial version of Premiere Pro?
I am trying to download a trial copy of Premiere Pro. When I go to this page: http://www.adobe.com/downloads/ and click on the "Try" link for Premiere it takes me to a page of Apps that can be downloaded, but Premiere is not listed as an available do
-
Dear All, I would like to inquire that if there exists any GUI based tool that can provide the same functionality as ANT(for building the project), plz inform me with details. Thanks and Regards, Suhas Pol
-
How do i recover ipad passcode?