Formula to find MAX
Hi,
I calculate 5 diffrent key figures in 5 different fomulas
in a query. Now In the 6th formula , I want to calculate the
maximum among (formula1 , form2 .. formula 5 ) and diplayed in
the Formula 6. This should happen for all the rows.
Let me know if somebody has idea about this.
Thanks.
HI,
You have to create 4 CKF's......
CKF1 = (Formula1>Formula2) * Formula1 + Formula2
CKF2 = (CKF1>Formula3)* CKF1 + Formula3
CKF3 = (CKF2>Formula4) * CKF2 + Formula4
CKF4 = (CKF3 > Formula5) * CKF3 + Formula5
Use the CKF4 in the display......You will get the Max value...Try this it will work.
Thanks/Tarak
Similar Messages
-
How to find max based on 2 columns.
Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
Column A represents date and column B represent time.
How would I find max value of column A and with results for A find Max for B.
example
A - - - - - - - - - -B
101010 - - - - - 202020
101011 - - - - - 202021
101012 - - - - - 202021
101010 - - - - - 202022
101012 - - - - - 202020
What I looking for is
A - - - - - - - - - - B
101012 - - - - - 202021
ThanksYou can try one of the following...
sql> select * from temp;
A B
101010 202020
101011 202021
101012 202021
101010 202022
101012 202020
1 select a,b from (
2 select a,
3 b,
4 rank () over (order by a desc, b desc) rnk
5 from temp
6* ) where rnk = 1
sql> /
A B
101012 202021
1 select a,b from (
2 select a,b from temp
3 order by a desc, b desc
4* ) where rownum = 1
sql> /
A B
101012 202021Please try to provide create table statements and insert data scripts instead of "select * from table".
It helps creating your case easier. -
Error in Dimension formula to find the average price
Hi all,
I have tried a dimension formula to find the average price of Product.
if the product is a parent level member then average price should be the average of the list price,other wise it should be the list price itself.
IIF([PRODUCT].CURRENTMEMBER.PROPERTIES("CALC")="N",[KEYFIGURES].[LISTPRICE],AVG(DESCENDANTS([PRODUCT].CURRENTMEMBER,[KEYFIGURES].[LISTPRICE],LEAVES)))
While i tried the same i received some strange error , i don know whether its having some dependency on the Customer dimension. since K0030101 is a memebr belonging to CUSTOMER dimension.
MDX statement error:"Value K0030101 for characteristic /CPMB/U6D7SXT un"
I'm not sure whether its an error with the formula i created or any dependancy issue or whether this scenario is possible using dimension formulas or not.
Thanks in advance .
Anila MohanHi everyone!
We are using BPC 7.5 NW SP08 and we've had the same error message while adding a formula to the Account dimension:
'MDX statement error: "Value 1 for characteristic /CPMB/S9D7Q23 un".
We then checked in BW for /CPMB/S9D7Q23 and found out that it was the Product dimension.
The solution for the issue was quite interesting. I had seen in another post that sometimes CALC property was not correctly determined for SP08. The solution proposed was to edit dimension members, clear ParentH1 column, process dimension, re-edit, paste back ParentH1 values and process dimension again. This corrected CALC property problem.
It also worked for my case. After doing it to Product dimension I tried again to set the formula in Account dimension and it worked!!
Hope this helps.
Regards,
Luigi Laporte -
Hi!
There are different records in PSA.
When I load to DSO I need only max value for key figure.
For example, data in PSA:
Char| KF
1| 2
1| 5
1| 3
2| 1
If I use Overwrite then result is:
1| 3
2| 1
If I use Sum then result is:
1| 10
2| 1
But I need followed reult:
1| 5
2| 1
How can I find max value for KF without using FM or Programs?Hi,
You can do this in a Start routine.
Sort the source package and copy the records with the max value to another internal table which has the same structure as your source package.
In the end of the routine, over write records in source package with the records in the internal table.
THis will help.
- Jaimin -
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
I tried a SELECT from (....) as follows*
select * from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES)
This is woking perfectly. But when I tried to do max(*) i.e select max(*) from ......... gives error again.
Can some one suggest me a query to full fill my requirement please.
Thanks
Rupesh
www.orachat.comHi, Rupesh,
rupesh.sreenivas wrote:
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
Anything inside quotes (including double-quotes) is case-sensitive. Everything not in quotes is capitalized before compiling. So
last_processed is the same as
"LAST_PROCESSED", but different from
"last_processed".
Don't use double-quotes. -
To find max effdt from a table
i am facing problem in finding max effdt for every employee from a table.
i have to fetch emplid's from a table according to a particular deptid but there are many entries for a employee depending on effdt.I have to fetch the entry which is of max effdt.
i wrote query like dis,is it ok?
select emplid,effdt from ps_job where deptid='10000' and effdt in (select max(effdt) from ps_job group by emplid)You need to correlate the effdt and the empid is some fashion There are a few ways to do this. The closest correct way to what you have is:
SELECT emplid, effdt
FROM ps_job o
WHERE deptid='10000' and
effdt IN (SELECT MAX(effdt) FROM ps_job i
WHERE i.emplid = o.emplid)A one-pass method, assuming you can use analytics would be:
SELECT emplid, effdt
FROM (SELECT emplid, effdt, deptid,
ROW_NUMBER() OVER(PARTITION BY emplid
ORDER BY effdt DESC) rn
FROM ps_job o)
WHERE deptid='10000' and
rn = 1John -
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
Find MAX date for Person XYZ , and also MIN date for same Person?
List of dates in Column A , list of Persons in Column B. My problem is that I have In C1 the formula which part of it is =SUMPRODUCT(MAX((B4:B200=A2)*A4:A200))) to find the MIN date for the person specified in cell A2, but this formula returns an error. Please help
Many thanks
NB: I use Numbers for the iPhone
ans Icloude Numbers beta in the iMac 21.5Hi atapp,
Here is my solution to your problem. The footer cell A11 is where you type your search. You could easily change this to C1 if tha makes more sense to you. Colomn C is where the action is and it could be hidden. The formulas in the two footer rows are =MAX(C) and =MIN(C) so even though they are in Column B they are looking at Column C.
The formula in C2 is filled down.
Give it a try.
quinn -
Formula for finding specific date in a Current Year
Hello ,
Can get a formula which i can use in variable to find date having first Thursday in a current Year.
So in case of Current Year i.e 2014 , Formula should return date as "01/02/2014"(mm/dd/yyyy)
Thanks & Regards
Gourav JoshiHi Gourav Joshi,
Create a variable as per below. it will give you "First Thursday" of the year.
First_Thursday=
If(DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=1) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-4)) Else
If (DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=2) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-3)) Else
If (DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=3) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-2)) Else
If (DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=5) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())+6)) Else
If (DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=6) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())+5)) Else
If (DayNumberOfWeek(RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1)))=7) Then RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())+4)) Else
RelativeDate(CurrentDate();-(DayNumberOfYear(CurrentDate())-1))
It will help you.
Regards,
Anish -
Thread use to find max and min in an array of objects??
Hello everyone,
I need to find the min and max int value in a array of Objects.
This has to be done using threads--like divide the entire array into 10 or so blocks and find the local min and max in each block., Each block is run on a thread and finally comparing them to find the global max and min.How should I do this? I am new to Java programming and in particular to threads.
Thanks for your time and patience in answering this newbie question.
JPHi,
if i understand your problem, you have a big array with a lot of int values and you need to create a few arrays with a part of the big one in each, next each in a thread find the max and the min, next return the max and the min of each thread and compare these max and min to obtain the globals max and min?
In that case you can create a class in which is your big array. you create a second class implementing Runnable, in its creator you put the instance of the
first class and 2 int which are the beginning and the ending index. in this class add a method run in this method you create a loop to compare the current value to the max and min values, and you replace if you need to do. In the first class you put the main where you create a few instance of the second class in a thread :
private Thread threadName = new Thread(new SecondClass(this, start, end));
Next you start all these thread:
threadName.start();
At the end of the run method of the second class you have to write your result in the max and min fields of the first class(int type, you have to create it)
Write it only if it's necessary (if the current max is > than the already existing max).
I think it's complete!
Sorry if it's not really easy to understand, I'm french, but you can answer if you have more questions.
S�bastien -
Example of Data:
A1
2222222345
2222222345
2222222345
2222222345
2222222346
2222222346
2222222347
2222222347
2222222347
2222222347
2222222347
2222222347
Examplae of answer I would like the formula to provide:
I also can not manually type coullum A I need the formula to auto full that aswel. As there is to much data.
A2
B2
2222222345
4
2222222346
1
2222222347
6Hi Jessica,
Here's my take on it, using the sample data in your original post, and using the same solution with the names in your question.
In the Data table, column A contains the list of numbers in your original post. I've rearranged them in random order to demonstrate that the order of entry does not matter for this method.
Data::Column B contains the names in your question, each assigned to one of the numbers in the body of your post.
Column C contains an index showing the first occurrence of each distinct number in Column A. This index is used to fill both columns in the Summary by Number table.
Column D contains an index showing the first occurrence of each distinct name in Column Bt. This index is used to fill both columns in the Summary by Number table.
Both formulas are the same, except for the columns referenced (highlighted in the second formula below).
Formula: Data::C2: =IF(COUNTIF($A$2:A2,A2)=1,MAX(C$1:C1)+1,"")
Formula: Data::D2: =IF(COUNTIF($B$2:B2,B2)=1,MAX(D$1:D1)+1,"")
Both formulas require that row 1 be a Header Row, and that the contents of C1 (and D1) be Text, nothing, or a zero. Both formulas are filled to the end of their respective columns.
Summary by Number contains two formulas.
A2: =IF((ROW()-1)>MAX(Data :: $C),"",LOOKUP(ROW()-1,Data :: $C,Data :: $A))
B2: =IF(LEN(A2)>0,COUNTIF(Data :: A,A2),"")
Both are filled down to the end of their respective columns.
The first formula checks if its row number minus 1 is greater than the maximum value in the index column. If that is TRUE, there are no more values to look up, and the formula returns an empty string (which appears 'blank'). If it is FALSE, the LOOKUP the value in Data::column A corresponding to the value of ROW()-1 in Data::column C.
The second formula checks the LENgth of the entry in the column to its left. If the length is greater that 0 characters, there is a countable value in the cell, and the formula passes control to COUNTIF, which counts the number of times that value is found in Data::column A. If the length of the value in the cell to the left is zero, then the cell contains an empty string, and the formula passes control to the part after the last comma, which enters an empty string in the cell containing the formula.
The formulas in Summary by Name are identical to these except for the (bolded) references. These are incremented to the right; C -> D, and A -> B to match the Data:: columns containing the names and the names index.
Regards,
Barry -
How to find max audio peak of combined audio tracks with effects applied?
Hello all,
I am working in PPro CS5.5.
Often when I am working on a timeline I have two audio tracks of the same songs, one from the camera and one from a separate sound recorder, synced on the timeline so they combine into one signal. Applied to these tracks I might have an E.Q. effect or highpass/lowpass filter. Now I know that the max peak of each track or individual clips is easy to find using the 'Audio Gain' menu item, what I am hoping for is the equivalent of that menu item but related to the final output after the two tracks signal has been added together and effects have been all been applied? It is a very laborious task to have to listen through the whole timeline to discover if the output is going over 0db, if there was a way I could locate on the timeline where the max output is, that would definitely solve the problem.
Finding the way to do this would save literally hours per project! It's the one thing that makes me inwardly groan when I have to effect the output volume, which I have to do most of the time.
Hopefully,
Peter.I have found audio to be more difficult to learn than video. Audio has so much more subtlety, where perceptions don't always equate to what seems obvious. With multiple tracks adding together things get very complex very fast and peak amplitude has very little relationship to volume. When you compress a waveform the volume can be increased! Who'd have thunk it? Then you have S/N ratios and harmonics, soft clipping and hard clipping... Which brings me to the option on the Dynamics Effect called Soft Clip that is a smoother kind of limiter.
It's amazing where a simple one line suggestion can lead you; having worked a bit more with the dynamics 'effect' I am deciding that I like it a lot. The automation is not absolute but it broadens the tolerances I can work within. Very liberating! -
Finding max value in column using java..
Hello there!!
I have a problem that i tried finding in google but did not get what i wanted.. that's why i hope you guys could help me out.
How do i find the maximum value in a column using resultset..
for example..
Connection con = DriverManager.getConnection("jdbc:mysql:///eproc","root", "");//eproc is dbase name in MySQL
Statement stmt=con.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT MAX(id) FROM cat_work_sor_category");now, how do i use resultset to make sure i get the max value and assign to integer variable...
Please do help me out.
Thankyou.Connection con =
DriverManager.getConnection("jdbc:mysql:///eproc","roo
t", "");//eproc is dbase name in MySQL
Statement stmt=con.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT MAX(id) FROM
cat_work_sor_category");
Integer MaxValue = new Integer(-1);
if(rs.next()){
MaxValue = rs.getInt(1);
int MAX_VALUE = MaxValue.intValue(); -
Hello,
I need to write a query that will look at two tables - one of which contains event information (pk = event_id), the other containing event_id's and broker_id's. One broker may have attended one or more events.
I need to find the most recent event that each broker attended. Also, it is possible that a broker attended more than one event on a given day, in which case I will need some logic that will prioritize which event to select if a broker attended more than one on the given max event date.
Any help with this sql would be greatly appreciated.
Thanks!
ChristineThe business is currently determining the priority of
all event types. Once that is clear, I'll need to
incorporate that logic into my sql statement.
However, I'm not sure how to do that using this
logic:
ROW_NUMBER () OVER (PARTITION BY broker_id ORDER BY
event_date DESC)
I haven't used row number over and partitioning
before, so I'm not sure how it works. If, forSearch the Oracle documentation or this site for "Analytic Functions". Specifically:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions137.htm#sthref1981
instance, the business decides that event type
priority is something like: 5, 7, 1, 3, 11,
2......., how would I include that logic in the
statement above?
Would it be better to just add a priority column on
my event_type lookup table?
Thanks to all of you for your help with this!!Note how the row_number() value is assigned a value of 1 if the event_date is more recent. It has been assumed that you are storing timestamps as well, in the "event_date" column.
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select
26 er.broker_id, e.event_date, e.type, e.event_id,
27 row_number() over (partition by er.broker_id order by e.event_date desc) as seq
28 from
29 event_registration er,
30 event e,
31 contacts c
32 where er.event_id=e.event_id
33 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 15:00:00 3 31 1
1000155 01/19/2006 08:02:25 1 30 2
7 rows selected.
test@ORA10G>
test@ORA10G>That's due to the way the ORDER BY clause in the analytic function (in bold) has been defined. For every broker_id (partition by er.broker_id), it orders the records, most recent first (order by e.event_date desc), and hands out a "row number".
If you want to go ahead with Case (B) earlier, then you need to order by event_type ascending, so that the lowest event_type would have a "row_number()" values of 1, thusly:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select
26 er.broker_id, e.event_date, e.type, e.event_id,
27 row_number() over (partition by er.broker_id order by e.type) as seq
28 from
29 event_registration er,
30 event e,
31 contacts c
32 where er.event_id=e.event_id
33 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 08:02:25 1 30 1
1000155 01/19/2006 15:00:00 3 31 2
7 rows selected.
test@ORA10G>
test@ORA10G>Note how the more recent meeting has been relegated because it did not have a lower value of event_type.
Thereafter you just select the records with seq = 1.
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select broker_id,event_date,type,event_id
26 from (
27 select
28 er.broker_id, e.event_date, e.type, e.event_id,
29 row_number() over (partition by er.broker_id order by e.type) as seq
30 from
31 event_registration er,
32 event e,
33 contacts c
34 where er.event_id=e.event_id
35 and er.broker_id=c.broker_id
36 )
37 where seq = 1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 08:02:25 1 30
6 rows selected.
test@ORA10G>
test@ORA10G>You could use a "priority" column, with values like, say, 1, 3 and 5 for low, medium and high priorities, for each event.
In that case, your query could be:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 1 as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 5 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 5 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 3 from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 1 from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select
28 er.broker_id, e.event_date, e.type, e.event_id,
29 row_number() over (partition by er.broker_id order by e.priority) as seq
30 from
31 event_registration er,
32 event e,
33 contacts c
34 where er.event_id=e.event_id
35 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 19:00:00 3 32 1
1000155 01/19/2006 15:00:00 3 31 2
1000155 01/19/2006 08:02:25 1 30 3
8 rows selected.
test@ORA10G>
test@ORA10G>And hence:
test@ORA10G>
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 1 as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 5 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 5 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 3 from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 1 from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select broker_id,event_date,type,event_id
28 from (
29 select
30 er.broker_id, e.event_date, e.type, e.event_id,
31 row_number() over (partition by er.broker_id order by e.priority) as seq
32 from
33 event_registration er,
34 event e,
35 contacts c
36 where er.event_id=e.event_id
37 and er.broker_id=c.broker_id
38 )
39 where seq=1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 19:00:00 3 32
6 rows selected.
test@ORA10G>
test@ORA10G>
test@ORA10G>If you go for mnemonic values of priority like, say, "L", "M", "H" then you could try something like:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 'H' as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 'M' from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 'M' from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 'H' from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 'L' from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 'L' from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 'M' from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 'H' from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select broker_id,event_date,type,event_id
28 from (
29 select
30 er.broker_id, e.event_date, e.type, e.event_id,
31 row_number() over (partition by er.broker_id order by (case e.priority when 'L' then 1 when 'M' then 2 when 'H' then 3 end) desc) as seq
32 from
33 event_registration er,
34 event e,
35 contacts c
36 where er.event_id=e.event_id
37 and er.broker_id=c.broker_id
38 )
39 where seq=1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 19:00:00 3 32
6 rows selected.
test@ORA10G>
test@ORA10G>to achieve the same result.
HTH,
pratz -
Find max and low of resource_limit
Hi,
Version :10.2.0.1 and 11.2.0.1
OS :Aix 6
I want to find maximum number of sessions(High water mark) in a given period time and lowest level in a given time and also for processes.
Lowest usage of temp/undo tablespace in a given time period?and also highest usage a given time?
Is there any views?
Any suggestions
Thanks.I want to find maximum number of sessions(High water mark) in a given period time and lowest level in a given time and also for processes.1.Database logon trigger
2.If auditing is enabled then DBA_AUDIT_SESSION;
3.You can get this information, if you had the statspack/AWR running at regular intervals (query PERFSTAT schema).
SELECT trunc (b.snap_time) day, max(value)
FROM stats$sysstat a, stats$snapshot b
WHERE a.name = 'logons cumulative' AND a.snap_id = b.snap_id
group by trunc (b.snap_time)
order by 1;
Satish @ session history information - oracle 10g
Lowest usage of temp/undo tablespace in a given time period?and also highest usage a given time?Different question, please open another thread.
Regards
Girish Sharma
Maybe you are looking for
-
Space designer causing cpu spike overload
Hope you guys can help with this, it's beginning to annoy me. I'm currently unable to use space designer reliably. I had this problem in Logic 8 and it's still happening in 9. I have one instance of SD in my current project and it's causing cpu spike
-
Under the hood of a Proxy Service WS Endpoint
I have a Proxy Service that is published as a SOAP Service using a contract first approach. My question: when deployed in the OSB, what exactly happens? Is it deployed in the WLS Webcontainer or the EJB Container? My second question: when constructin
-
I have a Mac Pro. Bought it 1 year ago. Sys Profiler tells me: Processor: 2 x 2.66 GHz Dual-Core Intel Xeon Memory: 2 GB 677 MHz DDR2 FB-DIMM Disk Utility tells me my two internal hard drives are as follows: ST3500641AS P Media (which I think is: Sea
-
Showing error 3194 while updating ios5
how am i update my ipad2 wifi+3g from ios4.3.5 to ios5? while showing error 3194 each time i tried to update.
-
Cannot save in .PSD files
I'm currently using a laptop with 1GB RAM and I don't know if the RAM is related to this problem but I had set my Photoshop CS5 performance to the fullest yet I still can't save in .PSD. When I click on Save As, nothing show up. Even when I used the