application of analytic function
SELECT C, CAL Table;THE OUTPUT IS:
C CAL
C1 701
C1 702
C1 703
C2 701
C2 702
C3 701
C3 702
C3 703
I want using the analytical function and
get outside like below
C CAL
C1 703
C2 702
C3 703
Please guide me how I can get
Thank you
Hello
with data as (
select 'C1' C, 701 CAL from dual union all
select 'C1', 702 from dual union all
select 'C1', 703 from dual union all
select 'C2', 701 from dual union all
select 'C2', 702 from dual union all
select 'C3', 701 from dual union all
select 'C3', 702 from dual union all
select 'C3', 703 from dual
)
select
c
,max(cal)
from data
group by
c
C;MAX(CAL)
C1;703
C2;702
C3;703
You can do this with analytics e.g.
select
c
,max(cal) keep (dense_rank first order by c) over (partition by c ) cal
from dat
C;CAL
C1;703
C1;703
C1;703
C2;702
C2;702
C3;703
C3;703
C3;703
but then you will always do a distinct finally
select distinct
c
,max(cal) keep (dense_rank first order by c) over (partition by c ) cal
from data
C;CAL
C3;703
C2;702
C1;703
Therefore, at last, you will prefer the group by anyway :-)
Concerning
Tags: Database
Similar Questions
-
[8i] can I use an analytical function, or do I need a subquery?
Hi all...
This should be a quick. I hope I can solve my problem with an analytic function, but I don't know if it's possible. Can I use a subquery if I have to, but I'd really rather not.
Here is a very simple version of what I'm trying to do:
I want the results:CREATE TABLE test123 ( field1 VARCHAR2(10) , field2 VARCHAR2(10) , my_date DATE ); INSERT INTO test123 VALUES ('value1', 'a',TO_DATE('12/31/1900','mm/dd/yyyy')); INSERT INTO test123 VALUES ('value1', 'b',TO_DATE('01/02/2010','mm/dd/yyyy')); INSERT INTO test123 VALUES ('value1', 'c',TO_DATE('01/05/2010','mm/dd/yyyy')); INSERT INTO test123 VALUES ('value2', 'a',TO_DATE('12/31/1900','mm/dd/yyyy')); INSERT INTO test123 VALUES ('value2', 'b',TO_DATE('01/01/2010','mm/dd/yyyy')); INSERT INTO test123 VALUES ('value2', 'c',TO_DATE('01/15/2010','mm/dd/yyyy'));
I started with the following query:FIELD1 FIELD2 -------------- value2 a value2 b value2 c value1 a value1 b value1 c
But the problem is the database has a date of 31 December 1900 ' as default / initial for any date field. I don't want these default values taken into account in my calculation of min. I tried to put a WHERE clause in my analytical function [WHERE my_date <>TO_DATE (' 12/31/1900 ',' mm/dd/yyyy')], but I kept getting an error message "missing right parenthesis", so it seems that you can not have a WHERE clause here... or I'm just something wrong?SELECT field1 , field2 FROM test123 ORDER BY MIN(my_date) OVER ( PARTITION BY field1 ) -- removed DESC here , field2
Moreover, it is a 8i database...
Edited by: user11033437 may 20, 2010 17:16: took the 'DESC' criteria out of my order by clause. In my real application, I need DESC, but not the example.Hello
A WHERE clause excludes rows in the results set. Whenever you want you can have a WHERE clause that was more limited (for example, something that would simply exclude MIN calculating values in the ORDER BY clause), then think CASE:
SELECT field1 , field2 FROM test123 ORDER BY MIN ( CASE WHEN my_date > TO_DATE ( '12/31/1900' , 'MM/DD/YYYY' ) THEN my_date END ) OVER (PARTITION BY field1) DESC , field2 ;
This puts the lines for "Value1" first.
The minimum my_date for "Value1" (after excluding the values of 1900) is later than the minimum for "Value2", so I think that you either made a mistake in the desired output, or you do not want sorted by descending order.As always, thanks for the display of the data of the sample and the results so clearly.
-
Hi all
gives error for maxm as invalid identifier.SELECT chp.acct_nbr,CHP.INBOX_ID, MAX (CHP.INBOX_ID) OVER (PARTITION BY chp.ACCT_NBR) NULL, 'TMQ', NULL, row_number() OVER (PARTITION BY CHP.ACCT_NBR ORDER BY CHP.INBOX_ID desc) AS MAXM FROM chapsapp.mod_qual chp WHERE MAXM=1
Hello
AJR says:
Hi allSELECT chp.acct_nbr,CHP.INBOX_ID, MAX (CHP.INBOX_ID) OVER (PARTITION BY chp.ACCT_NBR) NULL, 'TMQ', NULL, row_number() OVER (PARTITION BY CHP.ACCT_NBR ORDER BY CHP.INBOX_ID desc) AS MAXM FROM chapsapp.mod_qual chp WHERE MAXM=1
gives error for maxm as invalid identifier.
You cannot reference an alias for column (like MAXM) in the same request where it is defined. (Actually, there is one exception: in the ORDER BY clause.)
Also, the analytic function are calculated after the WHERE clause is applied, you cannot use analytics in the WHERE clause.The solution to these two problems is to calculate the analytical functions in a subquery, and then reference them in the clause WHERE (or wherever you want) a Super application.
So you're got query mutilated, but I think you are trying to do something like this:
WITH got_maxm AS ( SELECT chp.acct_nbr , CHP.INBOX_ID , MAX (CHP.INBOX_ID) OVER (PARTITION BY chp.ACCT_NBR) AS x , row_number () OVER (PARTITION BY CHP.ACCT_NBR ORDER BY CHP.INBOX_ID desc ) AS MAXM FROM chapsapp.mod_qual chp ) SELECT acct_nbr , inbox_id , x , NULL , 'TMQ' , NULL , maxm FROM got_maxm WHERE maxm = 1 ;
-
Original title - 7.2.241.1enRegInstaller.exe
Hello.
Today, JUST after I "Set Windows to update," twice, I got the disconcerting message:
"Paris 7.2.241.1enRegInstaller.exe of working and was closed".
A problem with the application to stop functioning properly. Windows will notify you if a solution is available. »
Any wisdom or experience with this? I'm on a 64-bit HP Pavilion older (dv7-1245dx) with this OS JUST-update Windows (Vista Home Premium).
Thank you.
GIES W
The solution has been found just uninstall bing bar, restart the computer, and if you want just bing toolbar to reinstall. This easy solution my system fixed. Bing has again reminded all my points that I have amassed
-
Cannot use analytical functions such as lag/lead in odi components 12 c except in the expression
Hi I am a beginner of ODI 12 c
I'm trying to get the last two comments made on the product for a given product id. and load them into a target.
I have a source table something like
Product SR_NO comments LAST_UPDATED_TS
1 good car 2015/05/15 08:30:25
1 car average 2015/05/15 10:30:25
Jeep 2 super 2015/05/15 11:30:25
1 car bad 2015/05/15 11:30:25
Jeep 2 horrible 2015/05/15 09:30:25
Jeep 2 excellent 2015/05/15 12:30:25
I want a target table based on their last timestamp updated as (last two comments)
SR_NO Comment1 Comment2
1 bad average
2 super excellent
I used the logic below to get records in SQL Developer but in ODI 12 c, I'm not able to do this by mapping a source to the target table by applying analytical functions to the columns in the target table. Can someone help me solve this problem
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
) M
WHERE RN = 1
;
UM, I'm afraid that ODI puts the filter too early in the request, if it generates:
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
WHERE RN = 1
) M
;
Instead of:
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
) M
WHERE RN = 1
;
Even by changing the 'run on Hint"of your component of the expression to get there on the source, the request will stay the same.
I think the easiest solution for you is to put everything before the filter in a reusable mapping with a signature of output. Then drag this reusable in your mapping as the new source and check the box "subselect enabled."
Your final mapping should look like this:
It will be useful.
Kind regards
JeromeFr
-
Which analytical function to use?
Hi gurus,DB - Oracle 11 g 2
I followed the examples of data in the table test_a.
col1 col2 col3
----- ------- --------
x y y
p q y
a b y
p q y
t r y
p q y
The col3 column is always 'y '. But here's the data p, q, there is repeated 3 times (duplicate) and if this is the case I want to update only the first recordings like "n" col3 it is to say p, q, n. rest will be as it is.
I am able to get the row_number() for it but not able to do this.
Select col1, clo2, clo3 row_number() over (partition by col2) arrested by col1 as test_a r_num
Would it be possible directly by any analytic function?
Thank you
SID
COL4 is logical...
Something like that?
with x as)
Select col1, col2 ' x' 'y', 'y' col3 col4 1 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 2 Union double all the
Select 'a' col1, col2 'b', 'y' col3 col4 3 of all the double union
Select 'p' col1, col2 'q', 'y' col3 col4 4 Union double all the
Select 't' col1, col2 'r', 'y' col3, col4 5 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 6 double
)
---
Select * from)
Select x.*,
ROW_NUMBER() on rn1 (score of col1, col2, col3 col4 sort),
ROW_NUMBER() on rn2 (partition by col1, col2, col3 col4 desc sorting)
x
)
where rn1 = 1 and rn2 <> 1;
Understand the logic and simply change SELECT a query to UPDATE...
-
Oracle 11g Release 2
I'm assuming that the best solution is the use of analytical functions.
create table test3 ( part_type_id varchar2(50) ,group_id number ,part_desc_id number ,part_cmt varchar2(50) ) / insert into test3 values( 'ABC123',1,10,'comment1'); insert into test3 values( 'ABC123',1,10,'comment2'); insert into test3 values( 'ABC123',2,15,'comment1'); insert into test3 values( 'ABC123',2,15,'comment2'); insert into test3 values( 'EFG123',25,75,'comment3'); insert into test3 values( 'EFG123',25,75,'comment4'); insert into test3 values( 'EFG123',25,75,'comment5'); insert into test3 values( 'XYZ123',1,10,'comment6'); insert into test3 values( 'XYZ123',2,15,'comment7'); commit; select * from test3; PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 1 10 comment2 ABC123 2 15 comment1 ABC123 2 15 comment2 EDG123 25 75 comment3 EDG123 25 75 comment4 EDG123 25 75 comment5 XYZ123 1 10 comment6 XYZ123 2 15 comment7 9 rows selected. Desired output: PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 2 15 comment1 XYZ123 1 10 comment1 XYZ123 2 15 comment2 RULE: where one part_type_id has multiple (2 or more distinct combinations) of group_id/part_desc_id NOTE: There are about 12 columns in the table, for brevity I only included 4.
Post edited by: orclrunner was updated desired output and rule
Hello
Here's one way:
WITH got_d_count AS
(
SELECT part_type_id, group_id, part_desc_id
MIN (part_cmt) AS min_part_cmt
COUNT AS d_count (*) OVER (PARTITION BY part_type_id)
OF test3
GROUP BY part_type_id, group_id, part_desc_id
)
SELECT DISTINCT
group_id, part_desc_id, part_type_id, min_part_cmt
OF got_d_count
WHERE d_count > 1
;
Output:
GROUP_ID PART_DESC_ID MIN_PART_CMT PART_TYPE_ID
------------ ---------- ------------ ------------
ABC123 1 10 comment1
ABC123 2 15 comment1
XYZ123 1 10 comment6
XYZ123 2 15 comment7
Analytical functions, such as the COUNTY and MIN, many global versions, in addition, it can give the same results. Use the analytical versions when each row of output corresponds to exactly 1 row of input and the aggregate and GROUP BY version when each line of output corresponds to a group of lines 1 or more input. In this issue, each line of output appears to be a group of input lines having the same group_id, part_type_id, and part_desc_id (I'm guessing just, this only has never stated), so I used GROUP BY to get 1 row of output for every input lines.
-
Truncate output of analytical function?
For example this query:
Select month, sum (tot_sales) monthly_sales,.
AVG (Sum (tot_sales)) (any order by month
between 1 above and 1 below) rolling_avg
orders
where year = 2001 and region_id = 6
Group by month;
gives me an output which includes several decimal places for the rolling_avg column.
Is there a way to truncate this? I tried to use the rounded outside the analytical function and surely enough, it didn't work. I can't think otherwise.
You can use an external selection on the result of this query
select trunc(rolling_avg) from ( rolling_avg query);
-
Nth salary using the analytic function
I use under function to calculate second highest with empno and deptno salary.
Is it possible to get the same result with another query without using Assembly only analytical functions condition.using and windows function is possible to get the desired output?
SELECT e.empno,
e.DEPTNO,
tmp. SAL as second_higher_salary
FROM emp e,.
(SELECT Empno,
DEPTNO,
SAL,
DENSE_RANK() (PARTITION BY deptno ORDER of sal) AS rnk
WCP
) tmp
WHERE tmp.deptno = e.deptno
and tmp.rnk = 2
EMPNO DEPTNO SAL
---------- ---------- ----------
7934 10 2450
7782 10 2450
7839 10 2450
7876 20 1100
7369 20 1100
7902 20 1100
7788 20 1100
7566 20 1100
7900 30 1250
7844 30 1250
7654 30 1250
7521 30 1250
7499 30 1250
7698 30 1250
7900 30 1250
7844 30 1250
7654 30 1250
7521 30 1250
7499 30 1250
7698 30 1250
Here's my solution:
Select empno,
DEPTNO,
FIRST_VALUE (sal) (PARTITION BY deptno ORDER by sal desc)
de)
SELECT EmpNo,
DEPTNO,
Decode (DENSE_RANK () OVER (PARTITION BY deptno order by sal desc), 1,-sal, sal) sal
WCP
)
/
EMPNO DEPTNO FIRST_VALUE (SAL) OVER (PARTITIONBYDEPTNOORDERBYSALDESC) ---------- ---------- -----------------------------------------------------
7782 10 2450 7934 10 2450 7839 10 2450 7566 20 2975 7876 20 2975 7369 20 2975 7788 20 2975 7902 20 2975 7499 30 1600 7844 30 1600 7654 30 1600 7521 30 1600 7900 30 1600 7698 30 1600 -
Why the different values for an analytic function of the same group/game
I have the suite of table I'll be using.
Select * from table1;
REC_ID | STATUS | DATE_FROM | DATE_TO
1. C | 7 January 2015 |
2. H | December 3, 2014. 6 January 2015
3. H | October 3, 2014. December 2, 2014
4. H | May 30, 2014. October 2, 2014
5. H | May 29, 2014 | May 29, 2014
6. H | April 16, 2014 | May 28, 2014
7. H | Tuesday, April 25, 2007 April 15, 2014
INSERT statement if you need.
TOGETHER TO DEFINE
CREATE THE TABLE1 TABLE:
(
NUMBER OF REC_ID,
VARCHAR2 (1 BYTE) STATUS NOT NULL,.
DATE_FROM DATE NOT NULL,
DATE OF DATE_TO
);
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM)
Values
(1, 'C', TO_DATE (7 JANUARY 2015 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(2, 'H', TO_DATE (3 DECEMBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (6 JANUARY 2015 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(3, 'H', TO_DATE (3 OCTOBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (2 DECEMBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(4, 'H', TO_DATE (MAY 30, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (2 OCTOBER 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(5, 'H', TO_DATE (29 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (29 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(6, 'H', TO_DATE (APRIL 16, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (28 MAY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into TABLE1
(REC_ID, STATUS, DATE_FROM, DATE_TO)
Values
(7, 'H', TO_DATE (APRIL 25, 2007 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (APRIL 15, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'));))
COMMIT;
I will exercise more analytical query...
Select rec_id date_from, date_to, status,
min (date_from) over (partition by order of status by date_from desc) min_dt_from_grp,
ROW_NUMBER() over (partition by order of status by date_from desc) rownumberdesc,
ROW_NUMBER() over (partition by order of status by ASC date_from) rownumberasc
FROM table1;
the query result
REC_ID | DATE_FROM | DATE_TO | STATUS | MIN_DT_FROM_GRP | ROWNUMBERDESC | ROWNUMBERASC
1. 7 January 2015 | C | 7 January 2015 | 1. 1
2. December 3, 2014. 6 January 2015 | H | December 3, 2014. 1. 6
3. October 3, 2014. December 2, 2014 | H | October 3, 2014. 2. 5
4. May 30, 2014. October 2, 2014 | H | May 30, 2014. 3. 4
5. May 29, 2014 | May 29, 2014 | H | May 29, 2014 | 4. 3
6. April 16, 2014 | May 28, 2014. H | April 16, 2014 | 5. 2
7. Tuesday, April 25, 2007 April 15, 2014. H | Tuesday, April 25, 2007 6. 1
If you look at the output above, it dates back in the min_dt_from_grp column.
MY question is if the analytical function calculates for a particular/set group, which is by statute and for what min (date_from) partition is 25-apr-2007 for the GROUP H (Status column), then why I have different values returned by the query above in the min_dt_from_grp column.
Hello
Because you have specified an ORDER BY clause for the analytical function. In doing so, you calculate the rows on a window. Since you have not specified a windowing clause, the default applies:
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
-
Analytical functions: FIRST vs FIRST_VALUE
Hello
Can someone please help me understand the difference between PRIME and FIRST_VALUE in Anaytic functions.
I tried below 2 queries, but I see the same output. The only difference I see is that the field of the SAL is ordered FIRST_VALUE, but not the FIRST.
SELECT ename,
DEPTNO,
SAL,
MIN (SAL) keep (dense_rank FIRST
ORDER BY sal) by (deptno partition) FIRST
EMP;
SELECT ename,
DEPTNO,
SAL,
FIRST_VALUE (SAL) over (partition BY deptno arrested by sal) FIRST
EMP;
With the help of: Windows 8.1
Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production
PL/SQL Release 12.1.0.1.0 - Production
"CORE 12.1.0.1.0 Production."
AMT for 64-bit Windows: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 - Production
Hello
Here is an example of when you can use the FIRST analytic function.
Say you want the average sal for each Department, but only for the first year (taken from the hiredate column) in the Department (i.e., the column called f in the query below).
WITH got_hireyear AS
(
SELECT deptno and ename, sal, hiredate
EXTRACT (YEAR FROM hiredate) AS hireyear
FROM scott.emp
)
SELECT deptno, hireyear, hiredate, ename, sal
AVG (sal) DUNGEON (DENSE_RANK FIRST ORDER BY hireyear)
COURSES (PARTITION BY deptno
) In the FORM f
FIRST_VALUE (sal) over (PARTITION BY deptno
ORDER BY hireyear
) AS fv
AVG (sal) over (PARTITION BY deptno
hireyear
), A
OF got_hireyear
ORDER BY deptno
hireyear
ename
;
Output:
HIREYEAR ENAME SAL HIREDATE DEPTNO F FV HAS
------ ---------- ----------- ---------- ------ --------- ------ ---------
10 1981 9 June 1981 CLARK 2450 2450 3725,00 3725.00
10 1981 17 November 1981 KING 5000 3725,00 2450 3725.00
10 1982 23 January 1982 MILLER 1300 3725,00 2450 1300.0020, 1980, 17 December 1980 SMITH 800 800.00 800.00 800
20, 1981, 3 December 1981 FORD 3000 800.00 800 2987.50
20, 1981, 2 April 1981 JONES 2975 800.00 800 2987.50
20, 1987, 23 May 1987 ADAMS 1100 800.00 800 2050.00
20, 1987, 19 April 1987 SCOTT 3000 800.00 800 2050.0030 1981 20 February 1981 ALLEN 1600 1566.67 950 1566.67
May 30 1981 1st 1981 BLAKE 2850 1566.67 950 1566.67
December 30 1981 3 1981 JAMES 950 1566.67 950 1566.67
30 1981 28 - sep - 1981 MARTIN 1250 1566.67 950 1566.67
30-08 - sep - 1981 1981 TURNER 1500 1566.67 950 1566.67
30 1981 22 February 1981 WARD 1250 1566.67 950 1566.67The analytical FIRST_VALUE function can do (except in the very special case where only 1 row has the lowest hireyear, as in deptno = 20). AVG analysis can do (except in the very special case that all lines have the same hireyear as in deptno = 30).
-
Hello experts.
I have data similar to what follows below
create table t1 ( id number(30), description varchar(4000) ); insert into t1 values (1, 'zone'); insert into t1 values (2, 'small'); create table t2 ( id number(30), place varchar(4000), info varchar(4000) ); insert into t2 values (1, 'USA', 'Class U'); insert into t2 values (1, 'Mexico', 'Class M'); insert into t2 values (2, 'Germany', 'Class G');
I need help with something similar to what follows below without using any analytic function
Description of the ID info Place
1 box USA class U
Mexico 1 M class
2 small Germany class G
Any help is appreciated. Thank you
Hello
user13328581 wrote:
... I use an older version of oracle. Oracle 7.
Normally, your developers are older than your software.
You should be able to do what you want with a self-join on t2; a copy (d) should be displayed, and the other copy (c) contains all related values you need for comparison.
SELECT t2d.id
DECODE (t2d.place
MAX (t2c.place)
t1.description
) AS description
t2d.place
t2d.info
FROM t1
, t2 t2d - display
t2 t2c - compare
WHERE t1.id = t2d.id
AND t2d.id = t2c.id
GROUP BY t1.description
t2d.id
t2d.place
t2d.info
ORDER BY t2d.id
t2d.place DESC
;
Output:
ID DESCRIPTION PLACE INFO
---------- -------------------- -------------------- --------------------
1 box USA class U
Mexico 1 M class
2 small Germany class G
I've tested this in Oracle 11, but it should work in Oracle 7.
If this isn't the case, you may need to create a view.
-
Hello
Don't you know that it is the analytical function used to access an earlier date for example table RRODUCT
Date amount CN code 25/09/2012 1000 20 26/09/2013 2000 15 27/09/2011 1000 8 28/09/2012 2000 12 29/09/2013 2000 2 30/09/2004 1000 4
and this table contains more than 1000 lines in difeerent years now, I want to get the amount in a given year and the previous year like this 20 + 15 + 12 + 4
I need analytical control that find the previous year 2012 if my year 2013 or find out if 2010 my 2011 yeaar
You can use the YEAR-1 right? SHIFT of analytic function can be used to access the previous line. Your condition is to get the value of the previous year and previous row not. If this isn't what you are looking for then can you post output necessary for data provided?
-
analytical functions in oracle
Hi I am new to oracle analytical functions
I do not know how to use and where to use real-time, please send me the useful any url for it.
I read in the Oracle Documentation , but it's not understand for me.
Please provide me with any other useful URL, I'll read to those.if you have examples, please report it in the present.
Thank you
Check this box:
-
HelloI have a doubt about this analytical function to lead,
I have this table,
create table test3 (no number, name varchar2 (30));
Insert into TEST3 (NO, NAME) values (1, 'fen');
Insert into TEST3 (NO, NAME) Values (3, 'DEN');
Insert into TEST3 (NO, NAME) values (2, 'Sun');
Insert into TEST3 (NO, NAME) values (2, 'sen');
Insert into TEST3 (NO, NAME) values (1, 'end');
COMMIT;I put like that with this request.
Select lead don't (don't) over (partition by any order of name), name of test3.NO NAME
1 fen
end
2 Sun
Sen
DENBut I need as below output, I am unable to get the third 'NO' that has a value, I get null for that, even if I partitioned
by the 'NO '.NO NAME
1 fen
end
2 Sun
Sen
3 DENPlease clear my doubt.
Thanks in advance.
Like this
Select decode (NWR, 1, no, null) no
name
de)
Select row_number() over (partition by any order by name) rno
None
name
of test3
)
Maybe you are looking for
-
10.11.5 update problem
Ok. I'm puzzled. Last week, I used the App Store to update my El Capitan OS X to the 10.11.5 update. Since my Mac Mini will not stop or restart on its own. I have to use the Terminal to Shut Down command. In Safe Mode I can get it to Shut Down normal
-
Heuristics allow to the addons continue working after the upgrade, they said. Firefox will not break your addons, they said. 19 > 20 Firefox broke the addon (if the installation of the same version still got running again)20 > 21 Firefox broke the ad
-
Store alu 1 TB - 8.3 filenames
OS: Windows Vista Home Premium SP2PC: Laptop HP 6735 s Yesterday I finally have unboxed my StorE alu 1 TB and started to copy files from my portable 250 GB Medion drive-and-Go for it. Some files and folders have now received the old as 8.3 file names
-
I can sign in iCloud online, but not in iTunes. Help?
Everything works with my username and password - through devices, AppStore, web, etc. But iTunes will not work. It acts like I'm attached in the wrong password each time. Any tips?
-
Photon: Best way to snap the back cover in place?
What is the best way to put the cover back on? What sequence I use, it seems that one of the plastic snaps is not committed.