query to calculate the value and produce new lines
QUARTER CUSTOMER PRODUCT RETAIL_SALES_AMT WHOLESALE_AMT01/01/2006 ABC VACUUM CLEANER 454234,00 65633456.00
01/04/2006 ABC VACUUM CLEANER 324562,00 45333234.00
01/07/2006 ABC VACUUM CLEANER 67845423.00 NULL
01/10/2006 ABC VACUUM CLEANER 67453453.00 NULL
01/01/2007 ABC VACUUM CLEANER 56754633.00 NULL
01/04/2007 ABC VACUUM CLEANER 45423434.00 NULL
Hi guys,.
It's a situation where I have to produce a few new lines with projections based on Q4 RETAIL_SALES_AMT
RETAIL_SALES_AMOUNT and fourth ' rs following WHOLESALE_AMT. As you can see from the sample data for a specific customer,
product I have populated only until 01/04/2006 retail_sales_amt but WHOLE_SALE amt for the same product and customer
are there up to 01/04/2007.
I have to produce a PROJECTED RETAIL_SALES_AMT and it must be inserted in a new line with an indicator to identify
a proposed line. Here, in this case I have to produce a new line of projection from 07/01/2006,10/01/2006 and 01/01/2007
the RETAIL_SALES_AMT. The method of calculation is provided for in:
retail_sales_amt scheduled for 07/01/2006=.345+ ((01/07/2006 whole_sales-01/04/2006 whole_sales) / (01/04/2006 whole_sale)))
* 01/04/2006 RETAIL_SALES_AMT and move forward to subsequent quarters.
Is it possible that I can use a query to produce these new lines by calculating the RETAIL_SALES_AMT on the fly, or any other
How to procedure.
Please help as it seems a little complicated.
Concerning
Published by: user626688 on October 27, 2009 11:26
Published by: user626688 on October 27, 2009 11:26
Published by: user626688 on October 27, 2009 11:27
Published by: user626688 on October 27, 2009 11:28
Published by: user626688 on October 27, 2009 11:31
Published by: user626688 on October 27, 2009 11:32
Hello
As far as I can tell, that's what you asked for:
WITH got_prev AS
(
SELECT table_x.*
, LAG (wholesale_amt) OVER ( PARTITION BY customer
, product
ORDER BY quarter
) AS prev_wholesale_amt
FROM table_x
-- WHERE ... -- Any filtering goes here
)
, tree AS
(
SELECT got_prev.*
, SYS_CONNECT_BY_PATH ( CASE
WHEN LEVEL = 1
THEN retail_sales_amt
ELSE ( .345
+ wholesale_amt
- prev_wholesale_amt
) / prev_wholesale_amt
END
, '*'
) AS path
FROM got_prev
START WITH retail_sales_amt IS NOT NULL
CONNECT BY retail_sales_amt IS NULL
AND quarter = ADD_MONTHS (PRIOR quarter, 3)
AND customer = PRIOR customer
AND product = PRIOR product
)
SELECT quarter
, customer
, product
, COALESCE ( retail_sales_amt
, eval_number ( LTRIM ( path
, '*'
) )
) AS retail_sales_amt
, wholesale_amt
, NVL2 ( retail_sales_amt
, 'F'
, 'T'
) AS projected_flag
FROM tree
ORDER BY customer
, product
, quarter
;
I posted earlier the eval_number function.
In this query, a group of consecutive quarters, where the first group a retail_sales_num and the rest of the members of the group are not, is treated as a hierarchy. The retail_sales_amt of all members (except the first) will be based on the previous, as well as the wholesale_amts past and present.
Say that a tree is 5 points of time (as in your examples of data). We can calculate the 2nd point in several ways: using analytical functions, for example. But we cannot use the same formula to calculate the 3rd point, because the calculation of section 2 must be completed before we can calculate the 3rd. It goes the same for the 4th and 5th.
This is CONNECT BY arrives. CONNECT BY is one thing in Oracle SQL that can be recursively; children may find themselves once their parents are found, in the same way we want to calculate the nth retail_sales_amt once the amount of the n-minus-1 has been calculated. To do this, we use SYS_CONNECT_BY_PATH, where the first element in the path is the retail_sales_amt given, and all others are the factor to multiply this number to get the next amount.
SYS_CONNECT_BY_PATH produces a string like ' * 324562 *. 4965935 *-. 0057739', which should be interpreted as a number. TO_NUMBER won't: TO_NUMBER cannot convert only a single numeric literal. Instead, we have a function defined by the user who put this string dynamically in the SELECT clause of a query, where it is interpreted as a numeric expression.
Tags: Database
Similar Questions
-
Process of calculation to calculate the value after submit after all validations
Hello
Please help with a possible approach or suggestions for the calculation process.
I have a calculation process after submit I want to calculate its value after that all validations are handled. Because this process of calculating trim is off of the first part of the input string of the user for the P3_USES element. Thus, for example consider; the user selects a value for P3_USES (point list manager) to be "TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC. So my calculation process just stripes off the coast of the first portion of the string and computes the value will be "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. It works fine when all postings on the page are placed without cooking.
The problem occurs, then the validation fails on the form. Once the validation fails, the calculation process; already calculates the value and the P3_USES value form element is set to "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. So, here the user solves the problem of validation and sends it again the form, but at this point the value is calculated again but this time that my string is "BCA"... BCA... BCA... 0.CA BC... CA IT BC"which is not correct, because my initial user string entry was"TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC.
So my question is how they treat the value of my calculation after all validations. While I can keep the original value of the P3_USES element. I'm using the version of Oracle APEX 4.0 and Oracle 10 g R2 database.
Thank you
Rambeau
Hello
Combine code of calculation and validation?
Perform the calculations in the process?
Use another element to contain the value 'real '?
Kind regards
Jari
-
How to calculate the second and minisecond for audio landmark
I'm doing a sound synchronization for the clip audio and video in Flash. I found a tutorial on the web, and it seems to work. However, I do not know how to calculate the second and the mini (deuxieme from mp3 file. The first frame has the following lines to set the duration for each animation:
Import class
Import net.quip.sound.SoundSync;
Stop the main timeline
Stop();
Create an instance of SoundSync
var ss:SoundSync = new SoundSync();
ss.addCuePoint ("IT", 20100);
ss.addCuePoint ("admin", 20000);
ss.addCuePoint ("maintenance", 19800);
ss.addCuePoint ("treatment", 16479);
ss.addCuePoint ("engineering", 14598);
as.addCuePoint ("logo_epa_npdes", 12356);
ss.addCuePoint ("construction", 8967);
ss.addCuePoint ("370 mg/j", 7896);
ss.addCuePoint ("mc_650, 000 ', 5439);
ss.addCuePoint ("130 mg/j", 3254);
ss.addCuePoint ("1938", 2439);
ss.addCuePoint ("vintage_mc", 0);
Use the instance of loading external MP3
ss.loadSound ("Scn04 - 05.mp3", true);
Create a listener object for the
cuePoint and onSoundComplete events
var listener: Object = new Object();
listener.cuePoint = function (): Void {}
Play();
}
listener.onSoundComplete = function (): Void {}
Play();
}
ss.addEventListener ("cuePoint", listener);
ss.addEventListener ("onSoundComplete", listener);
and the soundsync.as file as follows:
Import mx.events.EventDispatcher;
Import mx.utils.Delegate;
class net.quip.sound.SoundSync extends its {}
PROPERTIES
private var _cuePoints:Array;
private var _currentCuePoint:Number;
private var _interval:Number;
private var _intervalDuration:Number;
private var _secondOffset:Number;
Event dispatcher
public var dispatchEvent:Function;
public var addEventListener:Function;
private var removeEventListener:Function;
CONSTRUCTOR
public void SoundSync(target:MovieClip) {}
Super (target);
init();
}
METHODS
private function init (): Void {}
Initialize properties
_cuePoints = new Array();
_currentCuePoint = 0;
_intervalDuration = 200;
_secondOffset = 0;
Initialize the instance of the class as the valid event broadcaster
EventDispatcher.initialize (this);
}
Add Cue Point
public void addCuePoint(cuePointName:String,_cuePointTime:Number):Void {}
() _cuePoints.push
{
type: "cuePoint",.
name: cuePointName,.
time: cuePointTime,.
target: this
}
);
_cuePoints.sortOn ("time", Array.NUMERIC);
}
Get cue point
public void getCuePoint(nameOrTime:Object):Object {}
var counter: Number = 0;
While (counter < _cuePoints.length) {}
If (typeof (nameOrTime) == 'string') {}
If (_cuePoints [meter] .name == nameOrTime) {}
return _cuePoints [counter];
}
} Else if (typeof (nameOrTime) == 'number') {}
If (_cuePoints [meter] .time == nameOrTime) {}
return _cuePoints [counter];
}
}
counter ++;
}
Returns a null value.
}
Get the Index of the current Cue Point
private void getCurrentCuePointIndex(cuePoint:Object):Number {}
var counter: Number = 0;
While (counter < _cuePoints.length) {}
If (_cuePoints [meter] .name == cuePoint.name) {}
return the meter;
}
counter ++;
}
Returns a null value.
}
Get the next Cue Point index
private void getNextCuePointIndex(seconds:Number):Number {}
seconds (seconds) =? seconds: 0;
var counter: Number = 0;
While (counter < _cuePoints.length) {}
If (_cuePoints [meter] .time > = seconds * 1000) {}
return the meter;
}
counter ++;
}
Returns a null value.
}
Benchmark deleted
public void removeCuePoint(cuePoint:Object):Void {}
_cuePoints.splice (getCurrentCuePointIndex (cuePoint), 1);
}
Remove all Cue Points
public function removeAll_cuePoints (): Void {}
_cuePoints = new Array();
}
Beginning
public void start(secondOffset:Number,_loops:Number):Void {}
Super.Start (secondOffset, loops);
dispatchEvent ({type: "onStart", target: this});
Reset benchmark
_secondOffset = secondOffset;
_currentCuePoint = getNextCuePointIndex (secondOffset);
Poll for cue points
clearInterval (_interval);
_interval = setInterval (Delegate.create (this, pollCuePoints), _intervalDuration);
}
Load sound
public void loadSound(url:String,_isStreaming:Boolean):Void {}
super.loadSound (url, isStreaming);
clearInterval (_interval);
_interval = setInterval (Delegate.create (this, pollCuePoints), _intervalDuration);
}
Stop
public void stop(linkageID:String):Void {}
If {(linkageID)
Super.Stop (linkageID);
} else {}
Super.Stop ();
}
dispatchEvent ({type: "onStop", target: this});
Kill the ballot
clearInterval (_interval);
}
Survey benchmarks
private function pollCuePoints (): Void {}
If the current position is close to the cue point.
var time: Number = _cuePoints [_currentCuePoint] .time;
var span: Number = (_cuePoints [_currentCuePoint + 1] .time)? _cuePoints [_currentCuePoint + 1] .time: time + _intervalDuration * 2;
If (position > = time & & position < = span) {}
Send event
dispatchEvent (_cuePoints [_currentCuePoint]);
Advance to the next landmark...
If (_currentCuePoint < _cuePoints.length) {}
_currentCuePoint ++;
} else {}
_currentCuePoint = getNextCuePointIndex (_secondOffset);
}
}
}
EVENT HANDLERS
onSoundComplete
public function onSoundComplete (): Void {}
Kill the ballot
clearInterval (_interval);
Reset benchmark
_currentCuePoint = 0;
Send event
dispatchEvent ({type: "onSoundComplete", target: this});
}
}
any help will be greatly appreciated.Wuzhishan,
> Hi Dave, your tutorial is very cute and it is very useful.
Thank you! My daughter is cute. She inherited all of
me, so I have not left. ;)> I'm sorry that I don't have my question clearly.
No worries. :)
> I have listen mp3 in Windows Media Player and try to
> get both for the tail, I found it on the bottom of the
> player time indicates 00:26.I'm with you.
> How can I writer this number in the code? Is it 0026 or 26?
The code expects milliseconds, then 26 seconds would be written as
this:26000
If he said 01:22 (one minute and 22 seconds), you must write it like this:
82000
... which is 60 seconds for now, 22 seconds
side, then multiplied by 1,000 to get milliseconds.David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design." -
To build the waveform.vi function how to calculate the value of dt
Dear all
Please guide me How to calculate the value of dt according to waveform.vi of construction
My sampling rate is 25000 and I take 200000 samples.
Kind regards
Muhammad Irfan
It's all simple arithmetic. The inverse of the sampling frequency power of samples is then the dt or the time between samples the number of samples is not relevant.
-
Calculate intermediate values and calculated values
I use OPA for a week or two and now understand how to structure evaluations logics, hierarchies, etc.
Now, as the calculations become more complex, I was wondering if it is possible to calculate the variables to be used in further calculations.
A good example may be I want to calculate the age of the subject for use in several calculations later in the logic. I have an incoming parameter that provides the subject of birth date - can I somehow fill a variable like "age of the subject = the number of years between the date of the topic of birth and the date of the day? "I want to fill ' age of the subject ' with a number instead of evaluate what true or false - is it possible?
The second part of the question, it is that I want the web service to return "the age of the subject" as the parameter value.
Thank you!
In Oracle Policy Modeling, 'attributes', the 'entities' and the 'relationships' are the terms that you will be interested. Attributes can be Boolean, or can be a value of various types of data. Consult the help for your version and search attributes, entities and relationships. A base attribute such as 'age in years' value can be calculated from other attributes such as "the data of birth of the person." An attribute that is provided as input via an external system or via an interactive interview is also called a base level attribute, while a determined political base don attribute can be an intermediate attribute (both determined and used as a condition to determine another attribute), or call a top-level attribute (determine on the basis of politics) (, but not used as a condition). The aid also includes examples of policies that are used to calculate the values of attributes.
-
Query to find the Pages and the list of permissions associated with a particular role in PS
I want a query to find the Pages and the list of permissions associated with specific roles in PS.
For example, if we see the role of manager accounts payable, it conatins Pages and the list of permissions.
But, to get everything in EXCEL sheet by Manuel priocess's BIG job. So, can someone give me the query.
Please try under queries
The roles assigned to the list of Perm:
SELECT B.ROLENAME
OF PSCLASSDEFN A, PSROLECLASS B
WHERE (A.CLASSID = B.CLASSID
AND A.CLASSID =: 1).
List of Perm pages can access:
SELECT B.MENUNAME, B.BARNAME, B.BARITEMNAME, B.PNLITEMNAME, C.PAGEACCESSDESCR, B.DISPLAYONLY
OF PSCLASSDEFN A, PSAUTHITEM B, PSPGEACCESSDESC C
WHERE (A.CLASSID = B.CLASSID
AND A.CLASSID =: 1
AND B.BARITEMNAME > ' '
AND B.AUTHORIZEDACTIONS = C.AUTHORIZEDACTIONS)
-
Replace the carriage return or new line with a table space
Hello
I want to replace the carriage return or new line with space in my column of the database.
To do this, I'm using this query:
Select replace (replace (Comments, chr (10),' '), Chr (13),' ') OF Comments_Master
Comments_Master is the name of the table and comments is column that contains carriage return or new line.
But this query works as expected.
Once I run this query and run the query again "select * FROM Comments_Master", transport return and new line still exist.
Please let me know what is wrong with this query?
You write that data back you? This example shows that your sql should work. I thinnk the query that you just described is the updated one below.
create table blah (text varchar2 (100));
insert into bla values (' it's multi)
line of text ");"
Select * from blah.
Select replace (replace (text, chr (10),' '), Chr (13),' ') of bla.
Update text bla = replace (replace (text, chr (10),' '), Chr (13),' ');
Select * from blah.
-
identify the State of a new line created in VO before committing
Hello world
I use jdev 11.1.1.7.0
Is it possible to identify the State of a new line created in VO before committing (I mean that we can realize that this line is new without use of isDirty())
Habib
Concerning
Ashish Awasthi blogged about this earlier. I have used this method in all my projects since I found it, and it works fine.
http://www.awasthiashish.com/2014/04/performing-partial-rollback-undo.html
This code is the interesting part for your need:
public Integer getRowStatusTrans() {}
/ * Here the rank is variable reference in the collection, this expression returns an int value if it is
2 change
0-new
1 - unmodified
initialized-1-
*/
entityState bytes = this.getEntity (0) .getEntityState ();
return new Integer (entityState);
}
-
Start the report on a new line column
Hey guys,.
Anyway is to slice a report into two lines? It's just, I have a big report which goes across the page im wondering if it is possible to divide it so that it does not continue on the page. So start a column of the report on a new line...
T.I.A
StefanWell since you can not have 2 interactive reports on a single page, no...
otherwise, you could solve this problem with 2 separate reports
-
Calculate the start and end date in Connect By - during Hirerchy changes
/ * Formatted 05/20/2013 09:53 (PS5 v5.115.810.9015) * /.
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
Hello, can you please help me or guide me in the calculation of the dates of beginning and end to the underside of logic
I want to calculate the Hirerchy Manager to the Agent.
Then under query works fine and its giving me the expected results
But when there is a change in the Hirerchy Manager or manager gets promoted
Then I need to calculate the start date and end date.
CREATE TABLE PERSON_DTL ( SID VARCHAR2(10 BYTE), EMP_MGRS_ID VARCHAR2(10 BYTE), START_EFFECTIVE_DT DATE, END_EFFECTIVE_DT DATE ); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M100', 'M107', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M101', 'M102', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('A100', 'M100', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M100', 'M101', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M107', 'M102', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M102', 'M103', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M103', 'M104', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('A101', 'M105', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into PERSON_DTL (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT) Values ('M105', 'M106', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); COMMIT;
SELECT CONNECT_BY_ROOT (b.sid) agent_sid, TRIM ( LEADING ',' FROM SYS_CONNECT_BY_PATH (b.sid, ',') || ',' || b.emp_mgrs_id ) PATH, START_EFFECTIVE_DT Start_dt, END_EFFECTIVE_DT End_dt FROM PERSON_DTL b WHERE CONNECT_BY_ISLEAF = 1 START WITH sid IN ('A101', 'A100') CONNECT BY PRIOR b.emp_mgrs_id = b.sid
This is the results that i am getting now. AGENT_SID PATH START_DT END_DT A100 A100,M100,M101,M102,M103,M104 1/1/2010 12/31/9999 A100 A100,M100,M107,M102,M103,M104 1/1/2010 12/31/9999 A101 A101,M105,M106 1/1/2010 12/31/9999
Results Required A100 A100,M100,M101,M102,M103,M104 1/1/2010 5/18/2013 A100 A100,M100,M107,M102,M103,M104 5/20/2013 12/31/9999 A101 A101,M105,M106 1/1/2010 12/31/9999
WITH the CLAUSE will make it readable
SQL> with paths as 2 ( 3 SELECT CONNECT_BY_ROOT (b.sid) agent_sid, 4 TRIM ( 5 LEADING ',' FROM SYS_CONNECT_BY_PATH (b.sid, ',') 6 || ',' 7 || b.emp_mgrs_id 8 ) 9 PATH, 10 START_EFFECTIVE_DT Start_dt, 11 END_EFFECTIVE_DT End_dt,rownum rn 12 FROM PERSON_DTL b 13 START WITH sid IN ('A101', 'A100') 14 CONNECT BY PRIOR b.emp_mgrs_id = b.sid 15 ), 16 flagged as 17 ( 18 select agent_sid, 19 path, 20 start_dt, 21 end_dt,rn, 22 case when path like lag(path) over(order by rn)||'%' then 0 else 1 end flg 23 from paths 24 ), 25 summed as 26 ( 27 select agent_sid,path,start_dt,end_dt, 28 sum(flg) over(order by rn) sm 29 from flagged 30 ) 31 select agent_sid,max(path) path,max(start_dt) start_dt, 32 min(end_dt) end_dt 33 from summed 34 group by agent_sid,sm 35 order by agent_sid; AGENT_SID PATH START_DT END_DT ---------- ---------------------------------------- --------- --------- A100 A100,M100,M101,M102,M103,M104 01-JAN-10 18-MAY-13 A100 A100,M100,M107,M102,M103,M104 20-MAY-13 31-DEC-99 A101 A101,M105,M106 01-JAN-10 31-DEC-99
-
How to calculate the value of the parameter in siebel.
Hi all
I am new to this world of siebel.
I want to set the value of my settings.
How I calculate that which is appropriate and value which is the maximum for the parameters.
Thank youI assume you mean Max and Max MT Server tasks.
Please read the following on Supportweb: how to set the parameters of Max and Max MT Server tasks for the object Siebel Manager? [476018.1 ID]
-
Need a query to return the first and last date for a rowset.
Hello
I have a query which can be simplified to the following data, if
Assume that it is my dataset, with THE_VALUE of
Sign (Anum) therefore,-1, 0 or 1.
* (Sorry for crushed registration. "I can't understand this website's rich text formatting.) *
THE_VALUE THE_DATE THE_MEMBER
1 0 1 January 2007
1 0 1 February 2007
1 0 1 March 2007
1. 1 April 1, 2007
1 1 1 May 2007
1 0 1 June 2007
1. 1 July 1, 2007
1. 1 August 1, 2007
1 0 01 - sep - 2007
2 0 1 January 2007
2 1 February 1, 2007
2 0 1 March 2007
2. 1 April 1, 2007
2 1 1 May 2007
2 0 1 June 2007
-2 1 1 July 2007
2. 1 August 1, 2007
2. 1 01-sep-2007
3 0 1 January 2007
3. 1 February 1, 2007
3 0 1 March 2007
3 0 1 April 2007
3. 1 May 1, 2007
3 0 1 June 2007
3. 1 July 1, 2007
3. 1 August 1, 2007
3 0 01 - sep - 2007
I need to get the lines with the THE_MEMBER, the values of the first and the last
THE_DATE, where the value is - 1, and the date range is the last
set of lines to the Member, with the same value of THE_VALUE.
I tried the following to get the dates of first and last for a set
consecutive months with the same value for the Member.
SELECT the_member
the_value
the_date
first_value (the_date)
in the first_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
last_value (the_date)
during the last_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
OF togola
ORDER BY the_member
the_date;
At first, it seems to work, but then, when the return value
an old value, FIRST_DATE will be the first of all the lines containing
This value for the Member rather than the first of consecutive
rows with this value for the Member. Apparently the partitioning
occurs before the order.
THE_MEMBER THE_VALUE THE_DATE FIRST DATE LAST DATE
1 0 January 1, 2007 January 1, 2007 January 1, 2007
1 0 1 February 2007 1 January 2007 1 February 2007
1 0 1 March 2007 1 January 2007 March 1, 2007
1. 1 April 1, 2007 April 1, 2007 April 1, 2007
1. 1 May 1, 2007 April 1, 2007 may 1, 2007
1-0 June 1, 2007 January 1, 2007 June 1, 2007
1. 1 July 1, 2007 April 1, 2007 July 1, 2007
1. 1 August 1, 2007 April 1, 2007 August 1, 2007
1 0 01 - sep - 2007 1 January 2007 01-Sep-2007
2 0 January 1, 2007 January 1, 2007 January 1, 2007
2 1 1 February 2007 February 1, 2007 February 1, 2007
2 0 1 March 2007 1 January 2007 March 1, 2007
2. 1 April 1, 2007 February 1, 2007 April 1, 2007
2 1 1 May 2007 February 1, 2007 may 1, 2007
2-0 June 1, 2007 January 1, 2007 June 1, 2007
-2 1 1 July 2007 February 1, 2007 July 1, 2007
2. 1 August 1, 2007 February 1, 2007 August 1, 2007
2. 1 01-sep-2007 1 February 2007 01-Sep-2007
3 0 January 1, 2007 January 1, 2007 January 1, 2007
3. 1 February 1, 2007 February 1, 2007 February 1, 2007
3 0 1 March 2007 1 January 2007 March 1, 2007
3 0 April 1, 2007 January 1, 2007 April 1, 2007
3. 1 May 1, 2007 February 1, 2007 may 1, 2007
3 0 June 1, 2007 January 1, 2007 June 1, 2007
3. 1 July 1, 2007 February 1, 2007 July 1, 2007
3. 1 August 1, 2007 February 1, 2007 August 1, 2007
3 0 01 - sep - 2007 1 January 2007 01-Sep-2007
That's what I need to get in the end.
THE_MEMBER FIRST DAY DATE OF LAST
July 2 1 2007-01 - Sep - 2007
Any ideas would be really appreciated.
Published by: user10700981 on December 17, 2008 13:57Hello
We'll call the lines whose the_value =-1 'good' lines and lines with the_value! =-1 ranks of 'bad '.
For each value of the_value, we need the first and last values of the_date where
the last row in the group is good
(b) the current line is good
(c) there is a lot of lines from the current line to the end of the Group
Condition (a) is just a special case of (c).
Conditions (b) and (c) are similar: (b) if applied to the current line, (c) applies to all lines after him. They can easily be combined into a single test that counts the number of lines after the current line or bad.Which produces the results you requested of the sample data that you provided:
WITH count_bad AS ( SELECT the_member , the_date , COUNT ( CASE WHEN the_value != -1 -- assuming the_value is never NULL THEN 1 END ) OVER ( PARTITION BY the_member ORDER BY the_date DESC ) AS bad_cnt FROM table_x ) SELECT the_member , MIN (the_date) AS first_date , MAX (the_date) AS last_date FROM count_bad WHERE bad_cnt = 0 GROUP BY the_member ORDER BY the_member;
-
passing the value and to timed loop
Hello everyone,
I'm working on a VI that consists of a timed loop which takes values in a file every 6 ms and writes it to an output file. Inside this timed loop, there is also a MATLAB block that calculates a parameter based on the value. based on this parameter, that a marker is set to 0 or 1 (planned) to operate as a Boolean marker.
The problem arises when the marker is set to 1. I need an additional structure any that waits five seconds (without stopping the timed loop iterations) and a 'stop' button is not pressed an additional string is placed in the output file. I wish for the marker to get back to 0 if you press the 'stop' button and not string to put in the file.
The main problem seems to be the use of a structure outside the timed loop. I can't have a while loop or any structure that waits 5 seconds inside the timed loop. And if I let him out he does not have the value of the marker second structure during execution of the timed loop.
+ Any ideas on what the structure to be used during the 5 seconds Timeout? (I tried a while loop)
+ Use a local or global variable for the marker? (I tried briefly, but as a local variable, I couldn't choose a variable defined in the MATLAB block, and I don't understand global variables in LabVIEW)I enclose a simplified version of the VI as well as a sample input file in case it can help visualize.
Thank you
DAVASo far, there are a few problems with your solution, but first of all, I will try to help answer your original question.
You are right that you can't have a structure inside the timed loop which waits five seconds without blocking execution of the timed for the same period. You are also right that you cannot simply communicate through cables to an external structure. If you exit a loop of wire in the other, which creates a dependency of data flow, which means that the data loop cannot run at all until another loop ends its execution entirely and send data.
You have two options:
- Don't actually use a wait function to determine if the 5 seconds elapsed. Use the Express VI of time elapsed (search the palette). He just guard track of how much time has passed since the last reset. It does not wait. If you are safe to use inside your loop timed in a case that is triggered when the marker value becomes 1. Also check the Boolean command in this case Structure to decide if you should output the data in the file.
- Use an outer loop as in the example you posted, but use screws of the range of synchronization to send data between the parallel loop. Consider a queue.
But overall, I don't think there is much chance of this work very well. No way, the Matlab Script node running fast enough to run at a time of 6ms. Also no way it works in a deterministic way at all. He needs to communicate with an external program, so its execution time is really unlimited.
-
HP pavilion 15 laptop: retrieving the value already created new touchsmart
My Assistant to support told me to create a collection on my NEW computer laptop just bought in November. When I go to 'create' with a flash drive I get the message "the value already created recovery."
Help, please.
If you have not created previuosly recovery and get this message, you must call HP support in your region. Explain the problem and that they should send free if they are unable to resolve the error.
If you live in the United States, contact HP info here. -
Rewrite the query to improve the performance and the optimized below cost.
Oracle 10g.
----------------------
Query
UPDATE FACETS_CUSTOM. MMR_DTL
SET
CAPITN_PRCS_IND = 2,
FIL_RUN_DT = Current_fil_run_dt,
ROW_UPDT_DT = dta_cltn_end_dttm
WHERE CAPITN_PRCS_IND = 5
AND HSPC_IND = 'Y '.
AND EXISTS (SELECT 1
OF FACETS_STAGE. CRME_FUND_DTL_STG STG_CRME
WHERE STG_CRME. MBR_CK = MMR_DTL. MBRSHP_CK
AND MMR_DTL. PMT_MSA_STRT_DT BETWEEN STG_CRME. ERN_FROM_DT AND STG_CRME. ERN_THRU_DT
AND STG_CRME. FUND_ID IN ('AAB1', '1AA2', '1BA2', 'AAB2', '1AA3', '1BA3', ' 1 B 80 ', ' 1 HAS 80 '))
AND EXISTS (SELECT 1
OF FACETS_CUSTOM. FCTS_TMS_MBRID_XWLK XWLK
WHERE XWLK. MBR_CK = MMR_DTL. MBRSHP_CK
AND MMR_DTL. PMT_MSA_STRT_DT BETWEEN XWLK. HSPC_EVNT_EFF_DT AND XWLK. HSPC_EVNT_TERM_DT);
Explain the plan of the query
-----------------------------------------------
Hash value of plan: 3109991485
-------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
-------------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT. | 1. 148. 12431 (2) | 00:02:30 |
| 1. UPDATE | MMR_DTL | | | | |
| 2. SEMI NESTED LOOPS. | 1. 148. 12431 (2) | 00:02:30 |
|* 3 | HASH JOIN RIGHT SEMI | | 49. 5488. 12375 (2) | 00:02:29 |
| 4. TABLE ACCESS FULL | FCTS_TMS_MBRID_XWLK | 6494 | 64940 | 24 (0) | 00:00:01 |
|* 5 | TABLE ACCESS FULL | MMR_DTL | 304K | 29 M | 12347 (2) | 00:02:29 |
|* 6 | TABLE ACCESS BY INDEX ROWID | CRME_FUND_DTL_STG | 1. 36. 5 (0) | 00:00:01 |
|* 7 | INDEX RANGE SCAN | IE1_CRME_FUND_DTL_STG | 8. | 1 (0) | 00:00:01 |
-------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
3 - access("XWLK".") MBR_CK "=" MMR_DTL. " ("' MBRSHP_CK")
filter ("XWLK". "HSPC_EVNT_EFF_DT" < = INTERNAL_FUNCTION ("MMR_DTL". " PMT_MSA_STRT_DT') AND
'XWLK '. "" HSPC_EVNT_TERM_DT "> = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT")) "
5 - filter("CAPITN_PRCS_IND"=5 AND "HSPC_IND"='Y')
6 filter (("STG_CRME". "FUND_ID" = "1 HAS 80 ' OR 'STG_CRME'." " FUND_ID "="1AA2"OR"
'STG_CRME '. "FUND_ID"= '1AA3' OR 'STG_CRME'. "FUND_ID" = "1 B 80 ' OR 'STG_CRME'. '. "FUND_ID" = "1BA2" OR "
'STG_CRME '. "FUND_ID"= "1BA3" OR "STG_CRME". "FUND_ID"= "AAB1" OR "STG_CRME". ("FUND_ID"="AAB2") AND
'STG_CRME '. "" ERN_FROM_DT "< = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT") AND "
'STG_CRME '. "" ERN_THRU_DT "> = INTERNAL_FUNCTION ("MMR_DTL". "PMT_MSA_STRT_DT")) "
7 - access("STG_CRME".") MBR_CK "=" MMR_DTL. " ("' MBRSHP_CK")
I could not optimize this query for best performance and optimized the cost... Can someone guide me on this.
Thank you
DS
You think you're going to lines updates 85K, Oracle think it will update a line.
At the time where the existence of the first test runs that oracle think already up to 49 lines, which is probably why he uses the loop join nested for the second test. (In your version of Oracle, the subquery introduced existence a very bad assumption (small) on the amount of data will survive).
It is possible that you will get better performance if you hint Oracle using a hash join for testing the existence - and you might want to think what test will eliminate most of the data and that we can first force.
Having said that, however, note that MMR_DTL research is a considerable fraction of the cost of the query - and an analysis is an easy thing for Oracle cost properly - if, despite your comments on update a column with a clue to this topic, you will find that the query can be more effective if you use an index. This is more likely to be the case if data ' WHERE CAPITN_PRCS_IND = 5 AND HSPC_IND = 'Y' "is well grouped (perhaps the latest data added to the table).". " You could then reduce the cost of maintaining this index by creating an index based on a feature that indexes only the lines where the predicate are both true so that the 2 update deletes the index entries and allows the index remain as thin as possible.
Concerning
Jonathan Lewis
Maybe you are looking for
-
When I'm on IE, I can type in the web address, hit "enter" and be directed to the place where I want to go. It is now in the Firefox application. Pretty weird.
-
Laptop HP 15-g020se: Bios password
I have baught a used laptop, I try to install the android emulator so I had to activate VT from the Bios, so I tried to access the Bios, but I found the password defined for it that I do not know... How can I reset the bios pass or cancel any solutio
-
When I return in a project recently recorded on windows movie maker, all executives went black and have a yellow warning marker, the sound also went but the name of the track is always above executives
-
Hard drive crashed. Buy a new. How do I re-installed Office? I have re-instalation of XP disc but I never had a desktop drive. It was already installed on the computer
-
Hi, I have installed Premiere Pro yesterday, but I'm not abe to find what it installed anywhere. I'm under WIN 10.I find it in as installed creative cloud, but there is no button 'open' next to it. Not possible to find in the start menu. Searched for