assistance at the request of aging. don't know how to do this?
Guys im a bit stuck usually I have a small idea how even start my query but for it that I don't even know where to begin to tackleI have a table as follows.
create table TRRACCD (
TRRACCD_GRNT_CODE varchar2(6),
TRRACCD_TRANS_dATE date,
TRRACCD_AMOUNT number(17,2),
trraccd_detail_code varchar2(6))
with the data as followsINSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('15-FEB-10', 'DD-MM-RR'),19764.77,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('12-MAR-10', 'DD-MM-RR'),2054.29,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('20-APR-10', 'DD-MM-RR'),4111.46,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('14-MAY-10', 'DD-MM-RR'),2570.1,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('10-JUN-10', 'DD-MM-RR'),2176.16,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('12-JUL-10', 'DD-MM-RR'),4756.29,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('13-AUG-10', 'DD-MM-RR'),28500.62,'GCSH');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('16-AUG-10', 'DD-MM-RR'),3602.3,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('17-SEP-10', 'DD-MM-RR'),3995.79,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('11-OCT-10', 'DD-MM-RR'),3413.6,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('11-NOV-10', 'DD-MM-RR'),2119.86,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('10-DEC-10', 'DD-MM-RR'),5905.52,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('10-DEC-10', 'DD-MM-RR'),12008.21,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('11-JAN-11', 'DD-MM-RR'),-10574.05,'GBIL');
INSERT INTO TRRACCD (TRRACCD_GRNT_CODE, TRRACCD_TRANS_DATE, TRRACCD_AMOUNT, TRRACCD_DETAIL_CODE) VALUES ('400364',to_date('11-JAN-11', 'DD-MM-RR'),20241.9,'GBIL');
However what I need to do, is ending up with an ageing for elements of sums up so the expected output should be something liketbrraccd_grnt_Code 30-60 60-90 over90
400364 20,241.90 2119.86 7,370.09
if your confused about how i arrived at the 7370.90 is because i have to subtract entries with GCSH on them and i also need to take
entries that are - and applied them to the oldest period if the balance of the period is positive.
IM inclined to say I can make it work with sql but the only other way I can think of is to use plsql?... any suggestions or solutions would be greatly appreciated.the closest I got to acomplishing this query without pl is the following. I know is lame, but I need help.
SELECT TRRACCD_GRNT_CODE,
TRRACCD_TRANS_dATE,
TRRACCD_AMOUNT,
trraccd_detail_code,
round(sysdate - TRRACCD_TRANS_dATE) "total days"
--sum(case when round(sysdate - TRRACCD_TRANS_dATE)>190 then "greater then 190"end )
FROM TRRACCD
where trraccd_grnt_Code = '400364'
ORDER BY TRRACCD_GRNT_CODE,
TRRACCD_TRANS_dATE,
trraccd_detail_code;
Hello
You may have noticed a resemblance between all these CASE expressions. I think the code easier to debug and maintain if you factored out them like this:
WITH got_col_num AS
(
SELECT trraccd_grnt_code
, CASE
WHEN trraccd_detail_code = 'GCSH' THEN -trraccd_amount
ELSE trraccd_amount
END AS net_amount
, trraccd_detail_code
, CASE
WHEN trraccd_amount < 0 THEN 4
WHEN trraccd_trans_date > SYSDATE - 30 THEN 1
WHEN trraccd_trans_date > SYSDATE - 60 THEN 2
WHEN trraccd_trans_date > SYSDATE - 90 THEN 3
ELSE 4
END AS col_num
FROM trraccd
WHERE trraccd_trans_date <= SYSDATE
)
SELECT trraccd_grnt_code
, SUM (CASE WHEN col_num = 1 THEN net_amount END) AS "0-29"
, SUM (CASE WHEN col_num = 2 THEN net_amount END) AS "30-59"
, SUM (CASE WHEN col_num = 3 THEN net_amount END) AS "60-89"
, SUM (CASE WHEN col_num = 4 THEN net_amount END) AS "90 and over"
FROM got_col_num
GROUP BY trraccd_grnt_code
ORDER BY trraccd_grnt_code
;
Output (similar to the last output above):
TRRACC 0-29 30-59 60-89 90 and over
------ ---------- ---------- ---------- -----------
400364 20241.9 17913.73 2119.86 7370.09
Tags: Database
Similar Questions
-
The update has caused a problem with sending emails which I solved it with help, but now I can't send to several people without all of the addresses being shown as well as their address book names, even when I use the BCC field.
It's ahotmail/live/outlook.com/msn account? There were reports a few weeks that BCC was pleased supported if the account is accessible thanks to a 3rd - party such TB program, but it still worked if the account is accessible via webmail. I think that MS has been alerted to the issue, but I do not know if it has been resolved.
-
Whenever I start Firefox, my home page is displayed, and then another tab of a page I looked at in the past. I don't know how to do stop to load to the top of this additional page at startup and can't seem to find information on how to disable this junk page. Any suggestions? Thank you!!
Maybe you inadvertently set both pages to be your Homepage"(s)"?
-
Dear, that which which may concern,.
I do not want to promote the material for your business but I don't know how to do this. Could I be put in contact with the one dealing with promotion of contact from microsoft, or microsoft studios, anyone who takes care of the halo franchise.
Hello
Microsoft - unsolicited ideas
http://www.Microsoft.com/en-us/legal/intellectualproperty/copyright/default.aspx#O14343 industries manage Halo - check community and forums
https://www.halowaypoint.com/en-usI hope this helps.
--------------------------------------------------------------------------------------------
Rob Brown - Microsoft MVP<- profile="" -="" windows="" experience :="" bicycle="" -="" mark="" twain="" said="" it="">-> -
My Dell laptop refered me article 871122 # to fix the wifi feature. I don't know how to solve this problem. Could someone help me solve this?
Thank you and have a great day...original title: Internet connection via wireless networkHello
- What were the changes made before the issue started?
You can view these methods:
Method 1:
Please see the steps that are provided in this link:
http://support.Microsoft.com/kb/871122
Method 2:
In Windows network connection issues
-
I already buy Photoshop CC over the phone, but I don't know how to install it. What can I do?
Hello
You can access the following link and download/install Adobe Creative Cloud App. Once installed, connect with the Adobe ID (email) according to which the CC members was bought and go to the tab "' Apps'" and start the installation of Photoshop CC.
Download Adobe Creative cloud apps | Free trial of Adobe Creative Cloud
Thank you.
-
I can't uninstall all programs and it says fail to uninstall, even with the cleaner and I don't know how to reinstall
Moving to the cloud creative download & install
Hello
Please, try the following steps:
- Uninstall Adobe CC (Creative Cloud help |) Uninstall the creative Office Cloud app)
- Reboot the computer.
- Install the latest Adobe Creative cloud version from the link: CC help | Creative cloud desktop
Kind regards
Sheena
-
When I installed creative cloud for the first time I was not installed in the second computer and now I don't know how to do this. Can someone help me?
Hello
Please refer to the help documents below to download the application Adobe CC:
Download, install, update or uninstall applications
Kind regards
Sheena
Moving to the cloud creative download & install
-
I have been designing a new Web site and when I publish on BusinessCatalyst the index page shows a sign 'coming soon '? This has never happened before and I don't know how to solve this problem?
I have published on an existing site, but also a new site, but I get the same message?
Hello
Open the page that wants to set as your home page,
Click on more action-> set as start page
Now visit the site again, it should be good.
Let me know if you have any question.
-
It started earlier - don't know what settings caused this.
It is possible that you just recorded music in the right folder.
They are the same files?
One of them have small arrows shortened on them as your desktop icons have usually showing that they are shortcuts?
Compare file names / albums and report after return of screenshots.
Take screenshots,
Usually, you can press the SHIFT key (maybe the Alt key) or (FN key on your laptop) and press prtscrn.
Open microsoft Paint, and then click Paste on the top left.
Painting is located in the Accessories folder in all programs from the Start button.http://Windows.Microsoft.com/en-us/Windows7/using-paint
Then click on the blue button on the file and click Save as, click jpeg file type and name the file.
Upload to skydrive or photobucket in a public album and post a direct link to the file here.Or use the windows snipping tool,
http://Windows.Microsoft.com/en-us/Windows-Vista/use-Snipping-Tool-to-capture-screen-shots
Refer to this topic on how to make a public record and present screen shot here.
http://answers.Microsoft.com/en-us/feedback/forum/suggest/how-to-insert-an-image-into-a-post-at-answers/bdae0306-c3cb-4d31-ace9-7281ea1a8a73You can also look at this for the new format in skydrive
-
Yahoo freezes ot too computer, don't know how to solve this problem.
Yahoo hangs, I don't know how to fix it. I'm not too computer. Help in simple terms, if possible. Thank you!
Hello
As you have problems with Yahoo, I suggest that you ask for help to their help pages:
https://help.Yahoo.com/kb/helpcentral
"Yahoo helps Community Forums: join the discussion.
https://help.Yahoo.com/kb/SLN6407.html
See you soon.
-
When I try to open a torrent using magnet, I get the following message. Firefox doesn't know how to open this address because the Protocol (loving) is not binding to any program.
I had this problem and just reinstalled Firefox. Problem solved. In my case, I believe that it is through the installation of FlashGet. Although I uninstalled FlashGet, it had outstripped the Magnet links / Protocol. I hope this helps you with your instance. Fortunately, I had Setup for my version of Firefox (7.0.1) registered and used that but you might need to search for your current version or install a later version
-
Hello
I don't know that there is a simple answer. I have a Mac pro with Adobe cc and lightroom in the mode to develop my metadata displayed in large characters on the picture that is very entertaining and I would remove it. Thank you
Press the letter I (for information). This will toggle through modes of different file information. A mode will display the information constantly, another mode will display the information temporarily, and another mode Stop mode information completely.
-
whenever I'm on firefox it starts randomly redirect me to other sites I think that its because of one of my extensions, but I do not know how to check or what is the origin of the problem please help
Thank you fixed it
-
my computer crashes from time to time, there is no virus. I was told that I could restore it or re-start it menu programs can not find or know how to do.
Hello Sharon,Please go through the process by visiting this link:
Kind regardsJ Chambers
Maybe you are looking for
-
Satellite A305 - error message keep appearing from
Hello, I have a Satellite A305-S6857 laptopA few days ago to XP downgrade Vista. It worked well but suddenly yesterday when I restart windows,. * the system has recovered from a mistake of the serosa A log of this error has been created For more info
-
What model of Logitech wireless combo keyboard/mouse that works on a TV KDLEX645
-
on the two table of combing in one
Hi all I post a fight may convert an array of integer to a char array (byte) and I got a solution already http://forums.ni.com/t5/LabVIEW/how-to-display-char-code-properly/m-p/2596087#M780368 However, I have another problem while dealing with a table
-
HELP, I tried a lot of things. OK lets see windows xp pro. with sp3, all updates are installed. This is an old pc he had a CD in it, and I replaced it with another pc, in working condition. I think it's maybe in the settings, I don't know the right o
-
Hi all For the not 24 hours I tried to access my computer in normal mode. When I turn on the pc, it says "configuration data 1 of 3 steps...". 0% complete"he never spent 0% and within seconds, it automatically restarts and starts again. It's so frust