Understanding row_number() and using it in an analytic function
Dear all;
I have been playing around with row_number and trying to understand how to use it and yet I still cant figure it out...
I have the following code below
create table Employee(
ID VARCHAR2(4 BYTE) NOT NULL,
First_Name VARCHAR2(10 BYTE),
Last_Name VARCHAR2(10 BYTE),
Start_Date DATE,
End_Date DATE,
Salary Number(8,2),
City VARCHAR2(10 BYTE),
Description VARCHAR2(15 BYTE)
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values ('01','Jason', 'Martin', to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto', 'Programmer');
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('02','Alison', 'Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver','Tester')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('03','James', 'Smith', to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver','Tester')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('04','Celia', 'Rice', to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, 'Vancouver','Manager')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('05','Robert', 'Black', to_date('19840115','YYYYMMDD'), to_date('19980808','YYYYMMDD'), 2334.78, 'Vancouver','Tester')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('06','Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78,'New York', 'Tester')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('07','David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78,'New York', 'Manager')
insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City, Description)
values('08','James', 'Cat', to_date('19960917','YYYYMMDD'), to_date('20020415','YYYYMMDD'), 1232.78,'Vancouver', 'Tester')I did a simple select statement
select * from Employee e
and it returns this below
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto Programmer
02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver Tester
03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver Tester
04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver Manager
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver Tester
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York Tester
07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York Manager
08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver TesterI wrote another select statement with row_number. see below
SELECT first_name, last_name, salary, city, description, id,
ROW_NUMBER() OVER(PARTITION BY description ORDER BY city desc) "Test#"
FROM employee
and I get this result
First_name last_name Salary City Description ID Test#
Celina Rice 2344.78 Vancouver Manager 04 1
David Larry 7897.78 New York Manager 07 2
Jason Martin 1234.56 Toronto Programmer 01 1
Alison Mathews 6661.78 Vancouver Tester 02 1
James Cat 1232.78 Vancouver Tester 08 2
Robert Black 2334.78 Vancouver Tester 05 3
James Smith 6544.78 Vancouver Tester 03 4
Linda Green 4322.78 New York Tester 06 5
I understand the partition by which means basically for each associated group a unique number wiill be assigned for that row, so in this case since tester is one group, manager is another group, and programmer is another group then tester gets its own unique number for each row, manager as well and etc.What is throwing me off is the order by and how this numbering are assigned. why is
1 assigned to Alison Mathews for the tester group and 2 assigned to James Cat and 3 assigned Robert Black
I apologize if this is a stupid question, i have tried reading about it online and looking at the oracle documentation but that still dont fully understand why.
user13328581 wrote:
understanding row_number() and using it in an analytic functionROW_NUMBER () IS an analytic fucntion. Are you trying to use the results of ROW_NUMBER in another analytic function? If so, you need a sub-query. Analuytic functions can't be nested within other analytic functions.
...I have the following code below
... I did a simple select statementThanks for posting all that! It's really helpful.
... and I get this result
First_name last_name Salary City Description ID Test#
Celina Rice 2344.78 Vancouver Manager 04 1
David Larry 7897.78 New York Manager 07 2
Jason Martin 1234.56 Toronto Programmer 01 1
Alison Mathews 6661.78 Vancouver Tester 02 1
James Cat 1232.78 Vancouver Tester 08 2
Robert Black 2334.78 Vancouver Tester 05 3
James Smith 6544.78 Vancouver Tester 03 4
Linda Green 4322.78 New York Tester 06 5... What is throwing me off is the order by and how this numbering are assigned. why is
1 assigned to Alison Mathews for the tester group and 2 assigned to James Cat and 3 assigned Robert Black That's determined by the analytic ORDER BY clause. Yiou said "ORDER BY city desc", so a row where city='Vancouver' will get a lower namber than one where city='New York', since 'Vancouver' comes after 'New York' in alphabetic order.
If you have several rows that all have the same city, then you can be sure that ROW_NUMBER will assign them consecutive numbers, but it's arbitrary which one of them will be lowest and which highest. For example, you have 5 'Tester's: 4 from Vancouver and 1 from New York. There's no particular reason why the one with first_name='Alison' got assinge 1, and 'James' got #2. If you run the same query again, without changing the table at all, then 'Robert' might be #1. It's certain that the 4 Vancouver rows will be assigned numbers 1 through 4, but there's no way of telling which of those 4 rows will get which of those 4 numbers.
Similar to a query's ORDER BY clause, the analytic ORDER BY clause can have two or more expressions. The N-th one will only be considered if there was a tie for all (N-1) earlier ones. For example "ORDER BY city DESC, last_name, first_name" would mena 'Vancouver' comes before 'New York', but, if multiple rows all have city='Vancouver', last_name would determine the order: 'Black' would get a lower number than 'Cat'. If you had multiple rows with city='Vancouver' and last_name='Black', then the order would be determined by first_name.
Similar Messages
-
How to use group by in analytic function
I need to write department which has minimum salary in one row. It must be with analytic function but i have problem with group by. I can not use min() without group by.
select * from (select min(sal) min_salary, deptno, RANK() OVER (ORDER BY sal ASC, rownum ASC) RN from emp group by deptno) WHERE RN < 20 order by deptno;
Edited by: senza on 6.11.2009 16:09different query, different results.
LPALANI@l11gr2>select department_id, min(salary)
2 from hr.employees
3 group by department_id
4 order by 2;
DEPARTMENT_ID MIN(SALARY)
50 2,100
20 2,100
30 2,500
60 4,200
10 4,400
80 6,100
40 6,500
100 6,900
7,000
110 8,300
70 10,000
90 17,000
12 rows selected.
LPALANI@l11gr2>
LPALANI@l11gr2>-- Always lists one department in a non-deterministic way
LPALANI@l11gr2>select * from (
2 select department_id, min(salary) min_salary
3 from hr.employees
4 group by department_id
5 order by 2) where rownum = 1;
DEPARTMENT_ID MIN_SALARY
20 2,100
LPALANI@l11gr2>
LPALANI@l11gr2>-- Out of the departments with the same least salary, returns the one with the least department number
LPALANI@l11gr2>SELECT MIN (department_id) KEEP (DENSE_RANK FIRST ORDER BY salary) AS dept_with_lowest_sal, min(salary) min_salary
2 FROM hr.employees;
DEPT_WITH_LOWEST_SAL MIN_SALARY
20 2,100
LPALANI@l11gr2>
LPALANI@l11gr2>-- This will list all the deparments with the minimum salary
LPALANI@l11gr2>select department_id, min_salary
2 from (select
3 department_id,
4 min(salary) min_salary,
5 RANK() OVER (ORDER BY min(salary) ASC) RN
6 from hr.employees
7 group by department_id)
8 WHERE rn=1;
DEPARTMENT_ID MIN_SALARY
20 2,100
50 2,100 -
Trying to understand creating and using packages
Hi all,
I do not understand this problem... Package "shared.utilities" is an entire separate package from "alertsystem". When I comment out "package alertsystem", I get C:\Wdt\alertsystem\File_Handling.java:4: package shared.utilities does not exist
import shared.utilities.*;
^
Below is the code
// package alertsystem;
import shared.utilities.*;
import java.io.*;
import java.util.*;
import java.text.*;
class File_Handling
private long time_buff;
private String alertDir;
private String archPath;
private SData buff;
On the other hand, if I do NOT comment out "package alertsystem", no problem. I do not understand why I need to include "package alertsystem". If I am writing a simple module and want to use one of the library in "shared.utilities", do I always need to make sure all my codes come under a package?
Thanks in advance.Hi,
This is funny... if I do this....
package alertsystem;
import shared.utilities.*;
import java.io.*;
import java.util.*;
import java.text.*;
class File_Handling
private long time_buff;
private String alertDir;
without including the path to the jar file, NO PROBLEM during compilation and run (in this case, util.jar, which is actually the shared.utilities package). But, if I do
// package alertsystem;
import shared.utilities.*;
import java.io.*;
import java.util.*;
import java.text.*;
I still get the same error problem...
C:\Wdt\alertsystem\File_Handling.java:4: package shared.utilities does not exist
import shared.utilities.*;
In other words, if I include or I do not include the path of to the jar file and do this...
package alertsystem;
import shared.utilities.*;
import java.io.*;
import java.util.*;
import java.text.*;
Then, No problem with compilation and running. However, if I do not include "package alertsystem", I get compilation problem.
The jar file consists only of *.class files that I have compiled without a single problem. I included "package shared.utilities;" in all the files of the util.jar
Funny isn't it?
Thanks for responding.
Hi,
What's your classpath look like when you compile when
you include the package and when you don't include the
package? Is it when you compile or run the code? -
Staroffice Basic, Calc, passing and using ranges
Okay, I was trying to transfer a VBA function from Excel to StarOffice.
The routine call looks like this:
=PS_MUL($K$22:$K$277 ; $L$22:$L$277 ; $F$22:$F$277 ; F22)
That is, there are three ranges, and a value input.
Here is my attempt at STAROFFICE's version of this routine
Function PS_MUL(Tay1_A as Object, Tay2_A as Object, Rank_Vector, Rank_A as Long) as Double
Dim Product_sum as Double
Dim Element1 as Double, Element2 as Double
Dim i as Integer, j as Integer
Dim cell1 as Object, cell2 as Object
Product_sum=0
i=0
For Each Element1 in Rank_Vector
i=i+1
j=0
cell2=Tay2_A.GetCellByPosition(i,0)
For Each Element2 in Rank_Vector
j=j+1
cell1=Tay1_A.GetCellByPosition(j,0)
If Element1+Element2=Rank_A Then Product_sum=Product_sum+cell1.Value*cell2.Value
Next Element2
Next Element1
PS_MUL=Product_sum
End FunctionIn VBA, I simply refereced "Product_sum=Product_sum+Tay_1A( i ) * Tay_2A( j )"
That is, the input cell ranges are 1-D arrays, and Tay_1A was implicitly defined. So I just used them as arrays, and no problem.
Here, no matter what I try to do with my code, including getting a cell reference by position and taking its value or whatnot, I still get errors.
I think it is becoming clear to me that I don't understand how to pass and use range references in StarBasic.
If anybody could help me out with understanding passing and using these range references, I'd appreciate it.
Just for comparison, here is the function in VBA:
Function CombSumProd(Tay_1A, Tay2_A, Rank_Vector, Rank_A As Variant) As Variant
Dim Product_sum As Variant, Element1 As Variant, Element2 As Variant
Dim i As Integer, j As Integer
Product_sum=0
i=0
For Each Element1 in Rank_Vector
i = i+1
j = 0
For Each Element2 in Rank_Vector
j=j+1
If Element1+Element2=Rank_A Then
Product_sum=Product_sum+Tay1_A(i) *Tay2_A(j)
Next Element2
Next Element1
CombSumProd=Product_sum
End FunctionHi
Follow the steps below - (I am assuming that you are using BI queries in your model & your tabs are as per quarter - one tab for each quarter)
1. Create one radio button & in entry list create static list as 1 - Quarter 1, 2 - Quarter 2 & so on.
2. Now you want plan Vs actual in one graph & Currency in another. So create these reports for each quarter separately, so in all you will have 8 reports (2 for each quarter)
3. IN the layout you have to arrange it vary carefully, you take all the 'Plan Vs Actual' report for all the quarters & arrange them exactly one over the other. Same for Currency reports also.
4. NOw Give visibility condition for each report example - if report is for first quarter then condition will be - bool(if(radio button string=="1",true,false)) & assign the default value in radio button as 1. so that at the time of execution you will get these reports by default.
5. Like wise give condition for all.
6. When you execute this report you will get radio buttons at the top & as you select different buttons differents report will get opened.
7. As you have plased these exactly one over the other, user will not come to know these are different reports.
Try this method, if you have any doubts for this, please do ask me.
Regards
Sandeep -
I'm trying to sort a series of rows and look for the latest (based on time). I only want the latest row, because that's the one I want to update. I'm trying to figure out a query, and it looks like an analytical function is my best avenue, but the syntax is stymies me. Can someone help/suggest a correction?
select KEY_ID, to_char(START_DATETIME,'HH24:MI'), DESCRIPTION, FIRST_VALUE(KEY_ID)
OVER (PARTITION by KEY_ID ORDER BY START_DATETIME DESC) LIST
from TS_TIMECARD_DETAIL
where TIMECARD_ID = 60412
order by START_DATETIME DESC
/Thanks.
PS. Key_ID is unique/primary key.That was close enough. It's actually part of a trigger designed to match up pickup and delivery information. Here's what I finally came up with:
select KEY_ID, DESCRIPTION into x_key, x_desc
from (select KEY_ID, DESCRIPTION, START_DATETIME, MAX(START_DATETIME)
OVER (PARTITION by KEY_ID) MAX_START_DATETIME
from TS_TIMECARD_DETAIL
where TIMECARD_ID = x_tc
and START_DATETIME < v_dttm
order by START_DATETIME DESC)
WHERE rownum = 1; -
Having clause with Analytic function
can you pls let me know if we can use HAVING clause with analytic function
select eid,empno,sum(sal) over(partition by year)
from employee
where dept = 'SALES'
having sum(sal) > 10000I m getting error while using the above,
IS that we can use HAVING clause with partition by
Thanks in advanceYour having clause isn't using an analytical function, is using a regular aggregate function.
You also can't use analytical functions in the where clause or having clause like that as they are windowing functions and belong at the top of the query.
You would have to wrap the query to achieve what you want e.g.
SQL> ed
Wrote file afiedt.buf
1 select deptno, total_sal
2 from (
3 select deptno,sum(sal) over (partition by deptno) as total_sal
4 from emp
5 )
6 group by deptno, total_sal
7* having total_sal > 10000
SQL> /
DEPTNO TOTAL_SAL
20 10875
SQL> -
I successfully use the following analytical function to sum all net_movement of a position (key for a position: bp_id, prtfl_num, instrmnt_id, cost_prc_crncy) from first occurrence until current row:
SELECT SUM (net_movement) OVER (PARTITION BY bp_id, prtfl_num, instrmnt_id, cost_prc_crncy ORDER BY TRUNC (val_dt) RANGE BETWEEN UNBOUNDED PRECEDING AND 0 FOLLOWING) holding,
what i need is another column to sum net_movement of a position but only for the current date, but all my approaches fail..
- add the date (val_dt) to the 'partition by' clause and therefore sum only values with same position and date
SELECT SUM (net_movement) OVER (PARTITION BY val_dt, bp_id, prtfl_num, instrmnt_id, cost_prc_crncy ORDER BY TRUNC (val_dt) RANGE BETWEEN UNBOUNDED PRECEDING AND 0 FOLLOWING) today_net_movement
- take the holding for the last date and subtract it from the current holding afterwards
SELECT SUM (net_movement) OVER (PARTITION BY bp_id, prtfl_num, instrmnt_id, cost_prc_crncy ORDER BY TRUNC (val_dt) RANGE BETWEEN UNBOUNDED PRECEDING AND -1 FOLLOWING) last_holding,
- using lag on the analytical function which calculates holding fails too
I also want to avoid creating a table which stores the last holding..
Does anyone sees where I make a mistake or knows an alternative to get this value?
It would help me much!
Thanks in advance!Thank you,
but I already tried that but it returns strange values which are not the correct ones for sure.
It is always the same value for each row, if its not 0, and a very high one (500500 for example), even if the sum of all net_movement of that date is 0 (and the statement for holding returns 0 too)
I also tried witch trunc(val_dt,'DDD') with the same result (without trunc it is the same issue)
please help if you can, thanks in advance! -
how to ignore nulls in analytic functions ( row_number() and count())
Iam attaching test data can any one help me please
thanks in advanceeeee
CREATE TABLE TEMP_table
ACCTNUM NUMBER,
l_DATE TIMESTAMP(3),
CODE VARCHAR2(35 BYTE),
VENDOR VARCHAR2(35 BYTE)
insert into temp_table values (1,sysdate+1/60,'bso','v1');
insert into temp_table values (1,sysdate+2/60,'bsof','v1');
insert into temp_table values (1,sysdate+3/60,'bsof','v2');
insert into temp_table values (1,sysdate+4/60,'','v1');
ian executing this my ;
SELECT acctnum,l_date,vendor,code_1,
CASE
WHEN code = 'bsof'
AND COUNT (DISTINCT code) OVER (PARTITION BY acctnum, vendor) > 1
AND row_number () OVER (PARTITION BY acctnum, vendor ORDER BY vendor, l_date) != 1
THEN 'yes'
ELSE 'no' END result
FROM (select acctnum,l_date,vendor, code code_1, case when code IN ('bso', 'bsof') then code
else null end code from TEMP_TABLE
ORDER BY acctnum ,l_date);
my result :
1 3/23/2011 5:24:34.000 PM v1 bso no
1 3/23/2011 5:48:36.000 PM v1 bsof yes
1 3/23/2011 6:36:41.000 PM v1 bsof yes
1 3/24/2011 11:55:53.000 AM v1 no
1 3/23/2011 6:12:38.000 PM v2 bsof no
I need to eliminate nulls in top query not in inner query (not using where condition in inner query)
[\code] -
I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website
Here's two popup test sites.
http://www.kephyr.com/popupkillertest/test/index.html
http://www.popuptest.com/ -
I want to use QuickBooks for my very small bussiness, the recommendation from my accountant was QuickBooks (Windows). I just do not understand enough to decide whether to buy QuickBooks for Apple or Windows and use it in the Parallels world?
QuickBooks for Mac has been available again since at least 2004 (Intuit before that had done nothing with it for years). The current version is QB for Mac 2014. It's pretty much the same price no matter where you look.
The Mac version data is not directly compatible with the Windows version. Sending your data out to your business tax accountant and getting it back in is not at all easy. It's such a pain, our accountant comes here to finalize the books at year end.
There is still also a lot of Windows features for QB Pro which have never been added to the Mac version. They're all on the higher end side that larger businesses would need. I've never run into anything with the Mac version I couldn't do.
If your accountant wants ease of data transfer, then you'd be better off purchasing Snow Leopard Server and run that in Parallels. Then run the Windows version of QB in that. -
My daughter is using old round airport at college. I set it up originally without password protection because my macbook was too new to recognize the old style airport. I have an old iBook and I understand I can use that to set the passsword. But I can't seem to figure out even using the Airport admin how to establish a password. Any suggestions? Thanks.
If it even has that built-in, you would configure it using Airport Utility. It would likely be in the Wireless configuration for first turning on security and then setting the required password. For Macs you should use WPA Personal if the option is present.
-
I just turned off Find my iPhone after hearing about the hacking in Australia. I got an email from Apple saying: your Apple ID and password will no longer be required for someone to erase, reactivate, and use your iPhone. Does this mean that anyone can have access to my iPhone? I still have to put my passcode in.
What that means is the activation lock does not operate if you did what you said you did. Bottom line, turn it back on. That will then require anyone trying to use the device to have yoru Apple ID and password.
Barry -
Replacing Oracle's FIRST_VALUE and LAST_VALUE analytical functions.
Hi,
I am using OBI 10.1.3.2.1 where, I guess, EVALUATE is not available. I would like to know alternatives, esp. to replace Oracle's FIRST_VALUE and LAST_VALUE analytical functions.
I want to track some changes. For example, there are four methods of travel - Air, Train, Road and Sea. Would like to know traveler's first method of traveling and the last method of traveling in an year. If both of them match then a certain action is taken. If they do not match, then another action is taken.
I tried as under.
1. Get Sequence ID for each travel within an year per traveler as Sequence_Id.
2. Get the Lowest Sequence ID (which should be 1) for travels within an year per traveler as Sequence_LId.
3. Get the Highest Sequence ID (which could be 1 or greater than 1) for travels within an year per traveler as Sequence_HId.
4. If Sequence ID = Lowest Sequence ID then display the method of travel as First Method of Travel.
5. If Sequence ID = Highest Sequence ID then display the method of travel as Latest Method of Travel.
6. If First Method of Travel = Latest Method of Travel then display Yes/No as Match.
The issue is cells could be blank in First Method of Travel and Last Method of Travel unless the traveler traveled only once in an year.
Using Oracle's FIRST_VALUE and LAST_VALUE analytical functions, I can get a result like
Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
ABC | 01/01/2000 | 04/04/2000 | Road | Road | Air | No
ABC | 01/01/2000 | 15/12/2000 | Air | Road | Air | No
XYZ | 01/01/2000 | 04/05/2000 | Train | Train | Train | Yes
XYZ | 01/01/2000 | 04/11/2000 | Train | Train | Train | Yes
Using OBI Answers, I am getting something like this.
Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
ABC | 01/01/2000 | 04/04/2000 | Road | Road | <BLANK> | No
ABC | 01/01/2000 | 15/12/2000 | Air | <BLANK> | Air | No
XYZ | 01/01/2000 | 04/05/2000 | Train | Train | <BLANK> | No
XYZ | 01/01/2000 | 04/11/2000 | Train | <BLANK> | Train | No
Above, for XYZ traveler the Match? clearly shows a wrong result (although somehow it's correct for traveler ABC).
Would appreciate if someone can guide me how to resolve the issue.
Many thanks,
Manoj.
Edited by: mandix on 27-Nov-2009 08:43
Edited by: mandix on 27-Nov-2009 08:47Hi,
Just to recap, in OBI 10.1.3.2.1, I am trying to find an alternative way to FIRST_VALUE and LAST_VALUE analytical functions used in Oracle. Somehow, I feel it's achievable. I would like to know answers to the following questions.
1. Is there any way of referring to a cell value and displaying it in other cells for a reference value?
For example, can I display the First Method of Travel for traveler 'ABC' and 'XYZ' for all the rows returned in the same column, respectively?
2. I tried RMIN, RMAX functions in the RDP but it does not accept "BY" clause (for example, RMIN(Transaction_Id BY Traveler) to define Lowest Sequence Id per traveler). Am I doing something wrong here? Why can a formula with "BY" clause be defined in Answers but not the RPD? The idea is to use this in Answers. This is in relation to my first question.
Could someone please let me know?
I understand that this thread that I have posted is related to something that can be done outside OBI, but still would like to know.
If anything is not clear please let me know.
Thanks,
Manoj. -
Hi all,
I am using ODI 11g(11.1.1.3.0) and I am trying to make an interface using analytic functions in the column mapping, something like below.
sum(salary) over (partition by .....)
The problem is that when ODI saw sum it assumes this as an aggregate function and puts group by. Is there any way to make ODI understand it is not an aggregate function?
I tried creating an option to specify whether it is analytic or not and updated IKM with no luck.
<%if ( odiRef.getUserExit("ANALYTIC").equals("1") ) { %>
<% } else { %>
<%=odiRef.getGrpBy(i)%>
<%=odiRef.getHaving(i)%>
<% } %>
Thanks in advanceThanks for the reply.
But I think in ODI 11g getFrom() function is behaving differently, that is why it is not working.
When I check out the A.2.18 getFrom() Method from Substitution API Reference document, it says
Allows the retrieval of the SQL string of the FROM in the source SELECT clause for a given dataset. The FROM statement is built from tables and joins (and according to the SQL capabilities of the technologies) that are used in this dataset.
I think getfrom also retrieves group by clause, I create a step in IKM just with *<%=odiRef.getFrom(0)%>* and I can see that even that query generated has a group by clause -
HTMLDB 1.6 and "order by" in analytic functions
In HTMLDB 1.6, oracle 10g, when i enter the string "order by" in the region source of a report of the type "sql query (pl/sql function body returning sql query", I get
1 error has occurred
* Your query can't include an "ORDER BY" clause when having column heading sorting enabled.
I understand the reason for this error, but unfortunately i need this for an analytic function:
row_number() over (partition by ... order by ...)
It seems that the check is performed by simply looking for the string "order by" in the "region source" (in fact the error fires even if that string is contained within a comment).
I know possible workarounds (eg creating a view and select'ing from it), i just wanted to let you know.
Regards
AlbertoAnother one under the 'obvious route' category:
Seems that the ORDER BY check is apparentl for ORDER<space>BY... so simply adding extra whitespace between ORDER and BY bypasses the check (at least in 2.1.0.00.39).
To make it a bit more obious that a separation is intended, an empty comment, i.e. ORDER/*/BY*, works nicely
Edited by: mcstock on Nov 19, 2008 10:29 AM
Maybe you are looking for
-
Permissions problems, applications freezing, computer stalls
My MacPro started being very slow, so I attempted to repair disk permissions. After running it three times I continue to get the same message: Repairing permissions for "Main Hard Drive 1.5 TB" Permissions differ on "System/Library/Frameworks/JavaVM.
-
FYI Notification after final approval using AME
Hi, We have a requirement where we need to send a FYI notification to a group of people after final approval. Could you please guide if it can be done with the help of AME or not. If yes can you please tell me the detail steps. Regards, Rakesh.
-
Hi All,as we create Cost center Hierarchy, Profit center Hierarchy in DEV,Quality, can we Transport (if Yes, How?) both hierarchy to Production or do we nee to create one by again in Production? How to delete a cost center or Profit center from Hiera
-
How to use 'Extract Values' transformation?
Hi, I am new to EDQ. I have the following requirement - source system sends me partyname+address details. I need to check in the oracle database and if there is a match then send back the ID along with the input details. I am using Lookup check audit
-
i have an imac g4 purchased Dec 2003 runnung OS 10.5.8. It runs fine with airport off, but when I turn airport on it freezes with the black page, "restart by holding power key . . ." I swapped the airport extreme card with the one in my ibook G4 (