473,511 Members | 12,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windowing Function - 2

debasisdas
8,127 Recognized Expert Expert
FIRST_VALUE/LAST-VALUE:-
========================
THESE AGGREGATE FUNCTIONS CAN BE USED WITH WINDOWING FUNCTIONS TO IDENTIFY THE VALUES OF THE FIRST AND LAST VALUES IN THE WINDOW.

sample ex#1
---------------------
Expand|Select|Wrap|Line Numbers
  1. SELECT HIREDATE,FIRST_VALUE(SUM(SAL))OVER (ORDER BY HIREDATE ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) PREVOUS,
  2. SUM(SAL) MONTHLYSAL,
  3. LAST_VALUE(SUM(SAL)) OVER (ORDER BY HIREDATE ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) NEXT,
  4. AVG(SUM(SAL)) OVER (ORDER BY HIREDATE ROWS BETWEEN 2 PRECEDING  AND 2 FOLLOWING) ROLLING
  5. FROM EMP
  6. GROUP BY HIREDATE
  7. ORDER BY HIREDATE;
LAG/LEAD:-
==============
THESE FUNCTIONS ALLOWS ROWS TO BE REFERENCED BY THEIR POSITION RELATIVE TO THE CURRENT ROW.THESE ARE USEFUL FOR COMPAIRING ONE ROW OF A RESULT SET WITH ANOTHER ROW OF THE SAME RESULT SET.

Sample Ex1
-----------------------
Expand|Select|Wrap|Line Numbers
  1. SELECT HIREDATE,SUM(SAL) MONTHLYSAL,LAG(SUM(SAL),1) OVER( ORDER BY HIREDATE) PREVIOUS_MONTH_SAL
  2. FROM EMP GROUP BY HIREDATE ORDER BY HIREDATE;
Sample Ex2
-----------------------
Expand|Select|Wrap|Line Numbers
  1. SELECT HIREDATE,SUM(SAL) MONTHLYSAL,
  2. LAG(SUM(SAl),1) OVER( ORDER BY HIREDATE) PREVIOUS_MONTH_SAL,
  3. LEAD(SUM(SAl),1) OVER( ORDER BY HIREDATE) NEXT_MONTH_SAL
  4. FROM EMP GROUP BY HIREDATE ORDER BY HIREDATE;
Jul 4 '07 #1
0 5409

Sign in to post your reply or Sign up for a free account.

Similar topics

3
14908
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
2811
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
7663
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
31
2208
by: darwinist | last post by:
*With manual. http://darwinist.googlepages.com/htmldesktop.html Please criticise or contribute.
3
5018
by: darwinist | last post by:
http://darwinist.googlepages.com/htmldesktop.html What's the point of something like this? As a php programmer, everything is already there for me, except a decent client-gui system. I could...
3
1611
by: jefftyzzer | last post by:
Friends: Say I have a simple table like so: REGION (CHAR(3) SSN CHAR(9) ID SMALLINT With the following data:
0
3878
debasisdas
by: debasisdas | last post by:
WINDOWING FUNCTION:- ==================== ORACLE'S WINDOWING FUNCTIONS ALLOW AGGERGATES TO BE CALCULATED FOR EACH ROW IN A RESULT SET BASED ON A SPECIFIED WINDOW.THE AGGREGATION WINDOW CAN BE...
0
1953
by: jefftyzzer | last post by:
Friends: In v8 or v9 LUW, if I were to write (in Java or C) my own user-defined aggregate function, would I be able to use it in an OLAP windowing clause as I could use, e.g., COUNT or SUM? ...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.