SQL Help-How to achieve this?
Hi,
I have the following query on Oracle 10g:
SELECT year, cargo, Balance_ThisYEAR, Balance_PreviousYear_categ, PCT, a.TERMINAL_ID
FROM (
SELECT /*+ ORDERED */
extract(year from b.rsrc_util_date) as year,
'CN' AS cargo,
ROUND(SUM(c.summary_units), 0) Balance_ThisYEAR,
Round(LAG(SUM(c.summary_units)) OVER(ORDER BY b.TERMINAL_ID, extract(year from b.rsrc_util_date)), 0) Balance_PreviousYear_categ,
ROUND((SUM(c.summary_units) - LAG(SUM(c.summary_units)) OVER(ORDER BY b.TERMINAL_ID, extract(year from b.rsrc_util_date)))/LAG(SUM(c.summary_units)) OVER(ORDER BY b.TERMINAL_ID, extract(year from b.rsrc_util_date)) * 100,1) AS "PCT",
b.TERMINAL_ID terminal_id
FROM ...
Results are:
Year Cargo ThisYear PrevYear Percentage TerminalID
1998 CN 835 NLP
1999 CN 1288 835 54.3 NLP
2000 CN 1209 1288 -6.1 NLP
2001 CN 4708 1209 289.5 NLP
2002 CN 2545 4708 -45.9 NLP
2003 CN 358 2545 -85.9 NLP
2004 CN 817 358 128.2 NLP
2005 CN 1222 817 49.6 NLP
2006 CN 618 1222 -49.4 NLP
2007 CN 766 618 23.9 NLP
2008 CN 702 766 -8.4 NLP
2009 CN 543 702 -22.6 NLP
2010 CN 332 543 -38.9 NLP
2003 AU 125 NLP
2004 AU 2 125 -98.4 NLP
2008 AU 12494 2 624600 NLP
2009 AU 6936 12494 -44.5 NLP
1998 ST 25125 NLP
1999 ST 214 25125 -99.1 NLP
2000 ST 228 214 6.6 NLP
2001 ST 1936 228 748.5 NLP
2002 ST 104 1936 -94.6 NLP
2003 ST 54 104 -48.1 NLP
2004 ST 16337 54 30153.7 NLP
2005 ST 18260 16337 11.8 NLP
2006 ST 4896 18260 -73.2 NLP
2007 ST 2494 4896 -49.1 NLP
2001 RO 516 NLP
2005 RO 10 516 -98.1 NLP
The result is fine as long as there is a value for cargo for the previous year but when there is no previous year value the % should be 100 and not as it shows.
Example:For Cargo AU Year 2008 as there is no year 2007 the query calculates it with respect to last year in the database i.e. 2004.It calculates like:12494-125/12494=624600
Is there a way to get a value like 100% instead of 624600 wherever there is no immediate previous year?
I would like something like:
2003 AU 125 0 0 NLP
2004 AU 2 125 -98.4 NLP
2008 AU 12494 *0 100* NLP
2009 AU 6936 12494 -44.5 NLP
Any help in this regard will be highly appreciated.
Thanks
Edited by: user11401592 on Sep 28, 2010 9:14 AM
Give us some sample data to play with.
something like that should do it :with mytable as (
select 2003 year, 'AU' cargo, 125 summary_units, 'NLP' terminalid from dual
union all select 2004, 'AU', 2, 'NLP' from dual
union all select 2008, 'AU', 12494, 'NLP' from dual
union all select 2009, 'AU', 6936, 'NLP' from dual
union all select 2001, 'RO', 516, 'NLP' from dual
union all select 2005, 'RO', 10, 'NLP' from dual
select
year,
cargo,
case
when last_year is null or last_year!=(year-1) then cast(null as number)
else last_summ
end last_summ,
curr_summ,
case
when last_year is null or last_year!=(year-1) then 100
else trunc(100*v.curr_summ/v.last_summ,2)
end pct,
terminalid
from (
select
year,
lag(year)
over (partition by cargo, terminalid order by year) last_year,
cargo,
lag(summary_units)
over (partition by cargo, terminalid order by year) last_summ,
summary_units curr_summ,
terminalid
from mytable
) v;
YEAR CA LAST_SUMM CURR_SUMM PCT TER
2003 AU 125 100 NLP
2004 AU 125 2 1,6 NLP
2008 AU 12494 100 NLP
2009 AU 12494 6936 55,51 NLP
2001 RO 516 100 NLP
2005 RO 10 100 NLP
6 rows selected.
Similar Messages
-
How to Achieve this in SQL Query?
How to Achieve this ?
I have a table with numeric value populated like this
create table random_numeral (numerals Number(10));
insert into random_numeral values (1);
insert into random_numeral values (2);
insert into random_numeral values (3);
insert into random_numeral values (4);
insert into random_numeral values (5);
insert into random_numeral values (6);
insert into random_numeral values (56);
insert into random_numeral values (85);
insert into random_numeral values (24);
insert into random_numeral values (11);
insert into random_numeral values (120);
insert into random_numeral values (114);
Numerals
1
2
3
4
5
6
56
85
24
11
120
114
I want to display the data as follows
col1 / col2 / col3
1 / 2 / 3
4 / 5 / 6
11 / 24 / 56
85 / 114 / 120
Can anyone Help me?I hope there might be some simple way to do this and waiting for experts to reply.
Try the below query.
SQL> select * from random_numeral;
NUMERALS
1
2
3
4
5
6
56
85
24
11
120
NUMERALS
114
100
140
14 rows selected.
SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
2 (select numerals,rownum rn1 from
3 (
4 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
5 from random_numeral
6 )
7 where rn=1) a,
8 (select numerals,rownum rn1 from
9 (
10 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
11 from random_numeral
12 )
13 where rn=2) b,
14 (select numerals,rownum rn1 from
15 (
16 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
17 from random_numeral
18 )
19 where rn=0) c
20 where a.rn1=b.rn1(+)
21 and b.rn1=c.rn1(+)
22 /
A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
1 / 2 / 3
4 / 5 / 6
11 / 24 / 56
85 / 100 / 114
120 / 140 /
SQL>Cheers,
Mohana -
Hello,
I'm relatively new to Photoshop so if you know how to do this, please explain by telling me where I click. E.g. File>Open
Does anyone know how I would achieve this exact effect in Photoshop in the image above (without the circular logo)? The 2 light blue type of effects, one at the top of the image, the one at the bottom of the image. I don't know how to achieve this effect, please show me if you know how. I'm using Photoshop CS5.
I have looked through hundreds of tutorials, none provide me any clue as to how this is achieved.
Or does anyone know a tutorial on how this effect is achieved?
Thank you for your help.Yes, it would have been faster and more constructive to point out exactly where to find information rather than scold you.
Check out the Option bar that one gets under the Menu bar. If it is not showing, go to windows>Options.
More info: http://helpx.adobe.com/photoshop/using/tools.html#using_the_options_bar
If you select the brush tool, you will notice a flow value, that you can lower; and a Mode drop down list.
paint tool options: http://helpx.adobe.com/photoshop/using/painting-tools.html#paint_tool_options
Set the mode to Linear Dodge, then for the next stroke set it to lighten.
Blending modes explanations with links about their effects http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-77eba.h tml
Have fun learning Photoshop! -
Region
location
Dept
Budget Available
Allot Budget
Unused Budget
Decision for unused budget
US
200$
User Input
NY
100$
User Input
CA
100$
User Input
HR
50$
User Input
IT
50$
User Input
---------30$--------
20$
LOV
Add to Location
Use for Future Project
Add to Region
Spend as Bonus
How to achieve this tree table ?
My client wants that they should also be able to manage budge at Location or region level not only at the leaf(Dept) level.
I did a lot of research and finally found out that the details can only printed at the leaf(Dept) level.......
We can not hard code Region, locations and departments in table rows. When table tree is displayed we will only show all the regions... (US, UK, SA, IND, AUS, CAN,RUS, JPN.... etc..)
For Example:
Locations for US (NY, CA, OKH, WC...... etc.)
Locaitons for UK (SC, ENG, WL..... etc) and so on......
Departments for CA (HR, IT, ADMIN, FIN, TRVL, OPRN........ etc. ..)
Thanks in advance... It will be really great help if I get some breakthrough...
-RahulHi,
what if you add a transient attribute to those view objects? This way you don't need to change the table structure.
Frank -
Hi Friends,
I have the following requirement for Travel request workflow and Invoice approval workflow. Please let me know how to achieve this.
While sending a work item to sap inbox we will put the base BO in the task container right so that the approver can open the particular transaction.I need the same functionality in UWL but instead of the BO i need to place some link so that the user can open an iview or webdynpro application. Basically the user dont want to login to SAP GUI he needs everything to be done in Portal itself.
Do we need to do some settings in tcode SWFVISU for this or do we need to change the associated xml file in UWL to provide the link to iview. Please advice.Hi,
If i understand your requirement correctly, you want to place a link of BO in UWL but don't want that to get to SAP GUI. Right ?
I think it's possible. We had ECC 6.0 and EP 6.0 with SP 11. And, we had the requirement of showing up the TRIP BO in UWL thru' an iVIEW. We tried the SWFVISU and it didn't work. But, i think this facility has been taken care in later service packs. Pl approach SAP and they should be able to help you out. I'm not sure about the details of the solution SAP provided us, but it worked for us..like there will be a button "Display XXXXXX" which infact opens up your BO in UWL without logging into GUI.
Hope this helps.
venu -
How to achieve this photographic slide display/navigation
Hi,
I would like to know how to achieve the following:
1. Go to
http://www.corneliaadams.com/
& then click on 'michael mundy' link. this opens up a page with
a slideshow of photographs that i really love. I have very basic
knowledge of scripting ,a nd i usually achieve my goals by
modifying flas that i have seen or by following tutorials (as
opposed to writing it myself). the great thng about the above
version is taht the images slide to an exact position when you
click on the forward or back arrows, and they slow down ever so
slightly just before stopping. Can anyone point me in the right
directoin with how to achieve this, or offer a tutorial. I am
really starting from scratch, and would lik eto end up with the
same clean and professional outcome.
2. regarding the same above link, when you are at the main
site, and then you click the michael mundy' link, what is it that
happens, is it a new html popup page that opens of specified
dimensions and the embedded swf is set to stretch to maximum
width/height? or is it a lone swf that pops up (with no html page)?
or is that impossible?
Many Many Many thanks in advance,
CheskaI hope there might be some simple way to do this and waiting for experts to reply.
Try the below query.
SQL> select * from random_numeral;
NUMERALS
1
2
3
4
5
6
56
85
24
11
120
NUMERALS
114
100
140
14 rows selected.
SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
2 (select numerals,rownum rn1 from
3 (
4 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
5 from random_numeral
6 )
7 where rn=1) a,
8 (select numerals,rownum rn1 from
9 (
10 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
11 from random_numeral
12 )
13 where rn=2) b,
14 (select numerals,rownum rn1 from
15 (
16 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
17 from random_numeral
18 )
19 where rn=0) c
20 where a.rn1=b.rn1(+)
21 and b.rn1=c.rn1(+)
22 /
A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
1 / 2 / 3
4 / 5 / 6
11 / 24 / 56
85 / 100 / 114
120 / 140 /
SQL>Cheers,
Mohana -
Particle effect -how to achieve this kind of effect exactly
Hello please help me to achieve this type of flickering particle effect. how to achieve this in After effect which is shown at 0.8 sec to 0.11 in the attached link video. http://www.istockphoto.com/stock-video-2682258-hearts.php
I can't give you the exact settings but you could use Trapcode Particular with a custom particle or CC Particle world. Just turn gravity to 0 and set up a custom particle.
Your particle layer will be behind the spinning hearts layer. This should get you going in the right direction. -
How to achieve this type of Writing
I finally my Intuos tablet and I been trying to make this type of lettering, but I haven't had no luck. I been messing with the settings of the "Calligraphic" brushes and nothing. If someone out there knows how to achieve this and is willing to share the knowledge I'd be very helpful and I'd appreciate it it very much!
http://img209.imageshack.us/img209/1186/typevl0.jpg
Thanks!I'm afraid your expectations may be a bit unrealistic. That's not going to automatically happen by merely stroking away with a stylus using a Calligraphic Brush.
Whether you're using a stylus or a mouse for your input device, that kind of text design is drawn deliberately and carefully with the Pen tool, creating paths along the edges of the glyphs.
You
might achieve a rough sketch as a starting point, but even then it would be better (and most probably easier) done by drawing centerline paths with the Pen and applying the Calligraphic Brush to those paths. Better still, start with a pencil sketch, scan it, and just start tracing that with the Pen. Tracing text is excellent practice for learning to use the Pen.
JET -
Hi, when ever I'm using 3G, on my Iphone4 sim stops working and network is lost, this started after I updated my phone with 6.0.1(10A523)version. Please help how to solve this problem. Thanks.
Photos/videos in the Camera Roll are not synced. Photos/videos in the Camera Roll are not touched with the iTunes sync process. Photos/videos in the Camera Roll can be imported by your computer which is not handled by iTunes. Most importing software includes an option to delete the photos/videos from the Camera Roll after the import process is complete. If is my understanding that some Windows import software supports importing photos from the Camera Roll, but not videos. Regardless, the import software should not delete the photos/videos from the Camera Roll unless you set the app to do so.
Photos/videos in the Camera Roll are included with your iPhone's backup. If you synced your iPhone with iTunes before the videos on the Camera Roll went missing and you haven't synced your iPhone with iTunes since they went missing, you can try restoring the iPhone with iTunes from the iPhone's backup. Don't sync the iPhone with iTunes again and decline the prompt to update the iPhone's backup after selecting Restore. -
my Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem
Carlos-
Start by signing out and back in to see if it will see the subscription:
How to sign in and sign out of creative cloud (activate/deactivate)
If the apps are installed fine and close after launch see this link:
CC applications close immediately after launch
If the problem is something different, please let us know the error you see or what is happening on the screen so we can advise you on a solution
Pattie -
How to achieve this process in SAP SD module??
Hi,
I want to know whether this kind of scenario could be achieved in SAP system SD module??
We have only one material which the value or price is 10000USD, and this material could be only used 5 times. Everytime it is used, it will be goods issued in the system, and its value will be decreased 2000USD, this means this material will be drawn back into system and its value will be showed as 8000USD. And next time it will be 6000...4000...2000...0
After 5 times this kind of process, then this material is no-used any more.
I just want to know could 'Draw back' and 'decrease 2000USD everytime' 'show 'previous value - 2000' as new value every drawn back time' ....
how to achieve this in SAP SD system??
Thank you very much.Hi,
This can be mapped in Foreign trade.You need to use Licensing functionality.Each time you use it, it depreciate by document value.
Thanks,
Vrajesh -
I don't want my Time Capsule to link to Internet, does anyone know how to achieve this ? Thanks Don
Don,
We have no idea how you have your network set up, or what devices other than a Time Capsule that you might have, so it it impossible to provide an answer for you based on what we know at this time.
Can you provide some details so that we can understand how you have things setup, what devices that you have, etc?
The Time Capsule does need to connect to the Internet to receive firmware updates from Apple, so you would be missing out on some significant things......like a recent important security update....if you try to configure the Time Capsule to connect in the way that you ask about.
Backups will not be "automatic" if you configure the Time Capsule without an Internet connection. You will have to manually switch networks whenever you want to back up, and then switch back again to your "other" network for normal use. Quite a hassle for most users, even if it can be done. -
How to achieve this specific drop shadow effect?
Dear all,
Does anybody know how to achieve this specific drop shadow effect in InDesign: a step by step instruction, a plugin, etc?
Regards,
KasyanKasyan,
I generally just use the basic feather. I draw the object with a few clicks of the pen, fill with whatever color, set the tint if desired, then use settings more or less as below.
Mike -
How to achieve this Effect?
Hey everyone i was wondering if you guys had any idea how to achieve this effect in flash.....http://www.youtube.com/watch?v=QftcJtvLr8g
While you could probably do this in Flash, it is much more simply done using AfterEffects. There's a splendid text tool that can be tortured into effects like this. Have a look at the podcasts from Creative Cow on AfterEffects for some interesting examples.
-
How to achieve this in WebI?
Just create a measure for it. Here's an example in E-Fashion:
This is Sales Revenue for 2006; all I've done is added a new measure called "Target", which is just:
=900000
The chart is a combined chart. The Z Axis scale wasn't the same as the Y so I manually changed it to hard coded minimum and maximum values - you get the idea.
HTH
NMG
Maybe you are looking for
-
How do I find the icon for scanning to a PDF?
I used to have an icon for scanning to a PDF. Where should I find it?
-
How do I change the size of every page in an existing PDF? I'm using Acrobat 9.
-
Down arrow in scrolling bar has disappeared
On most screens the down arrow in the scrolling bar has disappeared or occupies the same space as the page expansion square in the lower right hand corner. Tried having the up arrow both at the top and at the bottom of the scrolling bar. Diappearance
-
Can't get old calendar onto new phone. Help!
Hi - just got a replacement Droid Inc. 2 for mine that was dropped and shattered yesterday. Having a problem getting my calendar from my old Inc. 2 to sync with my new Inc. 2. I've never kept a calendar on Google, just kept appointments on my phone.
-
Maintenance Optimizer - SMSY (ABAP + JAVA)
Hi gurus, I will try to explain what is my doubt/problem. We have a system ECC 6.0 with both stacks ABAP + JAVA. We want to do a support packages update, so I went to maintenance optimizer (MOPZ) and I choose that system, but during the process, afte